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