Commit f3306267 authored by Jeremy Roman's avatar Jeremy Roman Committed by Commit Bot

Store HashSet rather than unique_ptr<HashSet> in AXRelationCache::id_attr_to_related_mapping_.

It's more concise and skips some minor heap allocations.

Change-Id: I45259ae677da93cfed7b2c176ae519dfbd33acba
Reviewed-on: https://chromium-review.googlesource.com/1079029Reviewed-by: default avatarDominic Mazzoni <dmazzoni@chromium.org>
Commit-Queue: Jeremy Roman <jbroman@chromium.org>
Cr-Commit-Position: refs/heads/master@{#562951}
parent 1ce8fbce
...@@ -55,13 +55,9 @@ void AXRelationCache::UpdateReverseRelations(const AXObject* relation_source, ...@@ -55,13 +55,9 @@ void AXRelationCache::UpdateReverseRelations(const AXObject* relation_source,
// Add entries to reverse map. // Add entries to reverse map.
for (const String& target_id : target_ids) { for (const String& target_id : target_ids) {
HashSet<AXID>* source_axids = id_attr_to_related_mapping_.at(target_id); auto result =
if (!source_axids) { id_attr_to_related_mapping_.insert(target_id, HashSet<AXID>());
source_axids = new HashSet<AXID>(); result.stored_value->value.insert(relation_source_axid);
id_attr_to_related_mapping_.Set(target_id,
base::WrapUnique(source_axids));
}
source_axids->insert(relation_source_axid);
} }
} }
...@@ -207,12 +203,11 @@ void AXRelationCache::GetReverseRelated( ...@@ -207,12 +203,11 @@ void AXRelationCache::GetReverseRelated(
if (!element->HasID()) if (!element->HasID())
return; return;
String id = element->GetIdAttribute(); auto it = id_attr_to_related_mapping_.find(element->GetIdAttribute());
HashSet<AXID>* source_axids = id_attr_to_related_mapping_.at(id); if (it == id_attr_to_related_mapping_.end())
if (!source_axids)
return; return;
for (const auto& source_axid : *source_axids) { for (const auto& source_axid : it->value) {
AXObject* source_object = ObjectFromAXID(source_axid); AXObject* source_object = ObjectFromAXID(source_axid);
if (source_object) if (source_object)
source_objects.push_back(source_object); source_objects.push_back(source_object);
......
...@@ -109,7 +109,7 @@ class AXRelationCache { ...@@ -109,7 +109,7 @@ class AXRelationCache {
// quickly determine if it affects an aria-owns relationship. // quickly determine if it affects an aria-owns relationship.
// - When text changes, we can recompute any label or description based on it // - When text changes, we can recompute any label or description based on it
// and fire the appropriate change events. // and fire the appropriate change events.
HashMap<String, std::unique_ptr<HashSet<AXID>>> id_attr_to_related_mapping_; HashMap<String, HashSet<AXID>> id_attr_to_related_mapping_;
// Helpers that call back into object cache // Helpers that call back into object cache
AXObject* ObjectFromAXID(AXID) const; AXObject* ObjectFromAXID(AXID) const;
......
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