Commit ec4a3124 authored by Michael Lippautz's avatar Michael Lippautz Committed by V8 LUCI CQ

heap: Resolve -Wshadow warning in allocation-observer.cc

Bug: v8:12244, v8:12245
Change-Id: Id6b9e0a3986fb04c1a949b26ecf20da652ddd097
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/3181537
Auto-Submit: Michael Lippautz <mlippautz@chromium.org>
Reviewed-by: 's avatarDominik Inführ <dinfuehr@chromium.org>
Commit-Queue: Michael Lippautz <mlippautz@chromium.org>
Cr-Commit-Position: refs/heads/main@{#77045}
parent a0ace8a8
...@@ -4,6 +4,9 @@ ...@@ -4,6 +4,9 @@
#include "src/heap/allocation-observer.h" #include "src/heap/allocation-observer.h"
#include <algorithm>
#include <cstdint>
#include "src/heap/heap.h" #include "src/heap/heap.h"
#include "src/heap/spaces.h" #include "src/heap/spaces.h"
...@@ -58,15 +61,16 @@ void AllocationCounter::RemoveAllocationObserver(AllocationObserver* observer) { ...@@ -58,15 +61,16 @@ void AllocationCounter::RemoveAllocationObserver(AllocationObserver* observer) {
if (observers_.size() == 0) { if (observers_.size() == 0) {
current_counter_ = next_counter_ = 0; current_counter_ = next_counter_ = 0;
} else { } else {
size_t step_size = 0; // There's at least one observer.
const size_t min_next_counter =
for (AllocationObserverCounter& observer : observers_) { std::min_element(observers_.begin(), observers_.end(),
size_t left_in_step = observer.next_counter_ - current_counter_; [](const auto& a, const auto& b) {
DCHECK_GT(left_in_step, 0); return a.next_counter_ < b.next_counter_;
step_size = step_size ? std::min(step_size, left_in_step) : left_in_step; })
} ->next_counter_;
DCHECK_GT(min_next_counter, current_counter_);
next_counter_ = current_counter_ + step_size; const size_t min_step_size = min_next_counter - current_counter_;
next_counter_ = current_counter_ + min_step_size;
} }
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment