Skip to content

Commit b1ec34d

Browse files
committed
fix: avoid warnings on Windows
On Wndows, `size_t` is 64-bits, and `int` is 32-bits. That makes conversions from `size_t` to `int` potentially lossy, and they generate warnings. In this case an `int` variable was assigned to `size_t` and then passed to functions consuming `int`. Seems simpler to use `auto` and avoid these problems altogether.
1 parent da2c4a6 commit b1ec34d

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

src/google/protobuf/repeated_field.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -505,7 +505,7 @@ template <typename Element>
505505
inline RepeatedField<Element>::RepeatedField(const RepeatedField& rhs)
506506
: current_size_(0), total_size_(0), arena_or_elements_(nullptr) {
507507
StaticValidityCheck();
508-
if (size_t size = rhs.current_size_) {
508+
if (auto size = rhs.current_size_) {
509509
Grow(0, size);
510510
ExchangeCurrentSize(size);
511511
UninitializedCopyN(rhs.elements(), size, unsafe_elements());
@@ -786,7 +786,7 @@ inline void RepeatedField<Element>::Clear() {
786786
template <typename Element>
787787
inline void RepeatedField<Element>::MergeFrom(const RepeatedField& rhs) {
788788
ABSL_DCHECK_NE(&rhs, this);
789-
if (size_t size = rhs.current_size_) {
789+
if (auto size = rhs.current_size_) {
790790
Reserve(current_size_ + size);
791791
Element* dst = elements() + ExchangeCurrentSize(current_size_ + size);
792792
UninitializedCopyN(rhs.elements(), size, dst);

0 commit comments

Comments
 (0)