Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(288)

Side by Side Diff: src/value-serializer.cc

Issue 2326653002: Add a missing cast to ValueDeserializer::ReadVarint. (Closed)
Patch Set: Created 4 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2016 the V8 project authors. All rights reserved. 1 // Copyright 2016 the V8 project authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "src/value-serializer.h" 5 #include "src/value-serializer.h"
6 6
7 #include <type_traits> 7 #include <type_traits>
8 8
9 #include "src/base/logging.h" 9 #include "src/base/logging.h"
10 #include "src/conversions.h" 10 #include "src/conversions.h"
(...skipping 802 matching lines...) Expand 10 before | Expand all | Expand 10 after
813 // See also https://developers.google.com/protocol-buffers/docs/encoding 813 // See also https://developers.google.com/protocol-buffers/docs/encoding
814 static_assert(std::is_integral<T>::value && std::is_unsigned<T>::value, 814 static_assert(std::is_integral<T>::value && std::is_unsigned<T>::value,
815 "Only unsigned integer types can be read as varints."); 815 "Only unsigned integer types can be read as varints.");
816 T value = 0; 816 T value = 0;
817 unsigned shift = 0; 817 unsigned shift = 0;
818 bool has_another_byte; 818 bool has_another_byte;
819 do { 819 do {
820 if (position_ >= end_) return Nothing<T>(); 820 if (position_ >= end_) return Nothing<T>();
821 uint8_t byte = *position_; 821 uint8_t byte = *position_;
822 if (V8_LIKELY(shift < sizeof(T) * 8)) { 822 if (V8_LIKELY(shift < sizeof(T) * 8)) {
823 value |= (byte & 0x7f) << shift; 823 value |= static_cast<T>(byte & 0x7f) << shift;
824 shift += 7; 824 shift += 7;
825 } 825 }
826 has_another_byte = byte & 0x80; 826 has_another_byte = byte & 0x80;
827 position_++; 827 position_++;
828 } while (has_another_byte); 828 } while (has_another_byte);
829 return Just(value); 829 return Just(value);
830 } 830 }
831 831
832 template <typename T> 832 template <typename T>
833 Maybe<T> ValueDeserializer::ReadZigZag() { 833 Maybe<T> ValueDeserializer::ReadZigZag() {
(...skipping 645 matching lines...) Expand 10 before | Expand all | Expand 10 after
1479 if (stack.size() != 1) { 1479 if (stack.size() != 1) {
1480 isolate_->Throw(*isolate_->factory()->NewError( 1480 isolate_->Throw(*isolate_->factory()->NewError(
1481 MessageTemplate::kDataCloneDeserializationError)); 1481 MessageTemplate::kDataCloneDeserializationError));
1482 return MaybeHandle<Object>(); 1482 return MaybeHandle<Object>();
1483 } 1483 }
1484 return scope.CloseAndEscape(stack[0]); 1484 return scope.CloseAndEscape(stack[0]);
1485 } 1485 }
1486 1486
1487 } // namespace internal 1487 } // namespace internal
1488 } // namespace v8 1488 } // namespace v8
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698