Commit 280d700d authored by Darwin Huang's avatar Darwin Huang Committed by Commit Bot

Refactor: Replace excess uses of WTF::HashSet::Find with WTF::HashSet::Contains

- I saw that we use HashSet::Find(T Value) == HashSet::End(). HashSet::Contains
is simpler, so I figure we should change it where applicable. Thankfully, we
don't use Hashset::Find(..) == HashSet::End() too often.
- Likely no logic changes.

Change-Id: If6d595877318d0de9c8510a2b489871a16767c56
Reviewed-on: https://chromium-review.googlesource.com/c/1496249Reviewed-by: default avatarKentaro Hara <haraken@chromium.org>
Commit-Queue: Darwin Huang <huangdarwin@chromium.org>
Cr-Commit-Position: refs/heads/master@{#636745}
parent e511667b
...@@ -54,7 +54,7 @@ void CSSVariableAnimator::ApplyAll() { ...@@ -54,7 +54,7 @@ void CSSVariableAnimator::ApplyAll() {
while (!pending_properties_.IsEmpty()) { while (!pending_properties_.IsEmpty()) {
PropertyHandle property = *pending_properties_.begin(); PropertyHandle property = *pending_properties_.begin();
Apply(property); Apply(property);
DCHECK_EQ(pending_properties_.find(property), pending_properties_.end()); DCHECK(!pending_properties_.Contains(property));
} }
} }
......
...@@ -74,8 +74,7 @@ void WebFormElementObserverImpl::ObserverCallback::Deliver( ...@@ -74,8 +74,7 @@ void WebFormElementObserverImpl::ObserverCallback::Deliver(
if (record->type() == "childList") { if (record->type() == "childList") {
for (unsigned i = 0; i < record->removedNodes()->length(); ++i) { for (unsigned i = 0; i < record->removedNodes()->length(); ++i) {
Node* removed_node = record->removedNodes()->item(i); Node* removed_node = record->removedNodes()->item(i);
if (removed_node != element_ && if (removed_node != element_ && !parents_.Contains(removed_node)) {
parents_.find(removed_node) == parents_.end()) {
continue; continue;
} }
callback_->ElementWasHiddenOrRemoved(); callback_->ElementWasHiddenOrRemoved();
......
...@@ -164,7 +164,7 @@ bool AdTracker::IsKnownAdScript(ExecutionContext* execution_context, ...@@ -164,7 +164,7 @@ bool AdTracker::IsKnownAdScript(ExecutionContext* execution_context,
auto it = known_ad_scripts_.find(execution_context); auto it = known_ad_scripts_.find(execution_context);
if (it == known_ad_scripts_.end()) if (it == known_ad_scripts_.end())
return false; return false;
return it->value.find(url) != it->value.end(); return it->value.Contains(url);
} }
// This is a separate function for testing purposes. // This is a separate function for testing purposes.
......
...@@ -61,8 +61,7 @@ TEST_F(ImageElementTimingTest, ImageInsideSVG) { ...@@ -61,8 +61,7 @@ TEST_F(ImageElementTimingTest, ImageInsideSVG) {
const ImageElementTiming& timing = GetImageElementTiming(); const ImageElementTiming& timing = GetImageElementTiming();
// |layout_image| should have had its paint notified to ImageElementTiming. // |layout_image| should have had its paint notified to ImageElementTiming.
EXPECT_TRUE(timing.images_notified_.find(layout_image) != EXPECT_TRUE(timing.images_notified_.Contains(layout_image));
timing.images_notified_.end());
} }
} // namespace blink } // namespace blink
...@@ -194,12 +194,12 @@ void TextPaintTimingDetector::RecordText( ...@@ -194,12 +194,12 @@ void TextPaintTimingDetector::RecordText(
// This metric defines the size of a text by its first size. So it // This metric defines the size of a text by its first size. So it
// early-returns if the text has been recorded. // early-returns if the text has been recorded.
if (size_zero_node_ids_.find(node_id) != size_zero_node_ids_.end()) if (size_zero_node_ids_.Contains(node_id))
return; return;
// The node is reattached. // The node is reattached.
if (id_record_map_.Contains(node_id) && detached_ids_.Contains(node_id)) if (id_record_map_.Contains(node_id) && detached_ids_.Contains(node_id))
detached_ids_.erase(node_id); detached_ids_.erase(node_id);
if (id_record_map_.find(node_id) != id_record_map_.end()) if (id_record_map_.Contains(node_id))
return; return;
// When node_id is not found in id_record_map_, this invalidation is // When node_id is not found in id_record_map_, this invalidation is
// the text's first invalidation. // the text's first invalidation.
......
...@@ -234,8 +234,7 @@ void DatabaseTracker::CloseOneDatabaseImmediately(const String& origin_string, ...@@ -234,8 +234,7 @@ void DatabaseTracker::CloseOneDatabaseImmediately(const String& origin_string,
if (!database_set) if (!database_set)
return; return;
DatabaseSet::iterator found = database_set->find(database); if (!database_set->Contains(database))
if (found == database_set->end())
return; return;
} }
......
...@@ -1318,13 +1318,13 @@ void ThreadState::PushRegistersAndVisitStack() { ...@@ -1318,13 +1318,13 @@ void ThreadState::PushRegistersAndVisitStack() {
void ThreadState::AddObserver(BlinkGCObserver* observer) { void ThreadState::AddObserver(BlinkGCObserver* observer) {
DCHECK(observer); DCHECK(observer);
DCHECK(observers_.find(observer) == observers_.end()); DCHECK(!observers_.Contains(observer));
observers_.insert(observer); observers_.insert(observer);
} }
void ThreadState::RemoveObserver(BlinkGCObserver* observer) { void ThreadState::RemoveObserver(BlinkGCObserver* observer) {
DCHECK(observer); DCHECK(observer);
DCHECK(observers_.find(observer) != observers_.end()); DCHECK(observers_.Contains(observer));
observers_.erase(observer); observers_.erase(observer);
} }
......
...@@ -462,7 +462,7 @@ bool ResourceLoadScheduler::Release( ...@@ -462,7 +462,7 @@ bool ResourceLoadScheduler::Release(
if (id == kInvalidClientId) if (id == kInvalidClientId)
return false; return false;
if (running_requests_.find(id) != running_requests_.end()) { if (running_requests_.Contains(id)) {
running_requests_.erase(id); running_requests_.erase(id);
running_throttleable_requests_.erase(id); running_throttleable_requests_.erase(id);
......
...@@ -85,7 +85,7 @@ bool ParsedContentHeaderFieldParameters::HasDuplicatedNames() const { ...@@ -85,7 +85,7 @@ bool ParsedContentHeaderFieldParameters::HasDuplicatedNames() const {
HashSet<String> names; HashSet<String> names;
for (const auto& parameter : parameters_) { for (const auto& parameter : parameters_) {
const String lowered_name = parameter.name.LowerASCII(); const String lowered_name = parameter.name.LowerASCII();
if (names.find(lowered_name) != names.end()) if (names.Contains(lowered_name))
return true; return true;
names.insert(lowered_name); names.insert(lowered_name);
......
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