Skip to content

Commit

Permalink
fix: avoid warnings on Windows
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
coryan committed May 6, 2023
1 parent da2c4a6 commit b1ec34d
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/google/protobuf/repeated_field.h
Original file line number Diff line number Diff line change
Expand Up @@ -505,7 +505,7 @@ template <typename Element>
inline RepeatedField<Element>::RepeatedField(const RepeatedField& rhs)
: current_size_(0), total_size_(0), arena_or_elements_(nullptr) {
StaticValidityCheck();
if (size_t size = rhs.current_size_) {
if (auto size = rhs.current_size_) {
Grow(0, size);
ExchangeCurrentSize(size);
UninitializedCopyN(rhs.elements(), size, unsafe_elements());
Expand Down Expand Up @@ -786,7 +786,7 @@ inline void RepeatedField<Element>::Clear() {
template <typename Element>
inline void RepeatedField<Element>::MergeFrom(const RepeatedField& rhs) {
ABSL_DCHECK_NE(&rhs, this);
if (size_t size = rhs.current_size_) {
if (auto size = rhs.current_size_) {
Reserve(current_size_ + size);
Element* dst = elements() + ExchangeCurrentSize(current_size_ + size);
UninitializedCopyN(rhs.elements(), size, dst);
Expand Down

0 comments on commit b1ec34d

Please sign in to comment.