Commit 5b13731d authored by tzik's avatar tzik Committed by Commit Bot

Fix an std::remove_if usage in ContextualSuggestionsDebuggingReporter

container. Just move items to the end of the range.

std: :remove_if does not actually remove the selected element from the
Change-Id: I3868f83b027e85b36f9097e1325c69cb1a067875
Reviewed-on: https://chromium-review.googlesource.com/1078028Reviewed-by: default avatarPatrick Noland <pnoland@chromium.org>
Commit-Queue: Taiju Tsuiki <tzik@chromium.org>
Cr-Commit-Position: refs/heads/master@{#563143}
parent ff168dcc
......@@ -70,10 +70,12 @@ void ContextualSuggestionsDebuggingReporter::Flush() {
// Check if we've already sent an event with this url to the cache. If so,
// remove it before adding another one.
const std::string current_url = current_event_.url;
std::remove_if(events_.begin(), events_.end(),
[current_url](ContextualSuggestionsDebuggingEvent event) {
return current_url == event.url;
});
auto itr =
std::remove_if(events_.begin(), events_.end(),
[current_url](ContextualSuggestionsDebuggingEvent event) {
return current_url == event.url;
});
events_.erase(itr, events_.end());
events_.push_back(current_event_);
// If the cache is too large, then remove the least recently used.
......@@ -81,4 +83,4 @@ void ContextualSuggestionsDebuggingReporter::Flush() {
events_.erase(events_.begin());
}
} // namespace contextual_suggestions
\ No newline at end of file
} // namespace contextual_suggestions
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