Use HashSet<std::string> instead of unordered_set<>.
Change the default parameters for HashSet<std::string> to
allow passing StringPiece as a key, avoiding an unnecessary
allocation. Use the HashSet<std::string> instead of
std::unordered_set<std::string>. Rename HashSet<> functions
that mirror std::unordered_multiset<> to lower-case.
Fix CompilerDriver::LoadImageClasses() to avoid using
invalidated iterator.
Test: m test-art-host-gtest
Test: testrunner.py --host
Change-Id: I7f8b82ee0b07befc5a0ee1c420b08a2068ad931e
diff --git a/runtime/class_table.cc b/runtime/class_table.cc
index e313ec5..a233357 100644
--- a/runtime/class_table.cc
+++ b/runtime/class_table.cc
@@ -37,7 +37,7 @@
ReaderMutexLock mu(Thread::Current(), lock_);
TableSlot slot(klass);
for (ClassSet& class_set : classes_) {
- auto it = class_set.Find(slot);
+ auto it = class_set.find(slot);
if (it != class_set.end()) {
return it->Read() == klass;
}
@@ -49,7 +49,7 @@
ReaderMutexLock mu(Thread::Current(), lock_);
TableSlot slot(klass);
for (ClassSet& class_set : classes_) {
- auto it = class_set.Find(slot);
+ auto it = class_set.find(slot);
if (it != class_set.end()) {
return it->Read();
}
@@ -119,14 +119,14 @@
ReaderMutexLock mu(Thread::Current(), lock_);
size_t sum = 0;
for (size_t i = 0; i < classes_.size() - 1; ++i) {
- sum += classes_[i].Size();
+ sum += classes_[i].size();
}
return sum;
}
size_t ClassTable::NumReferencedNonZygoteClasses() const {
ReaderMutexLock mu(Thread::Current(), lock_);
- return classes_.back().Size();
+ return classes_.back().size();
}
mirror::Class* ClassTable::Lookup(const char* descriptor, size_t hash) {
@@ -145,12 +145,12 @@
TableSlot slot(klass);
WriterMutexLock mu(Thread::Current(), lock_);
for (ClassSet& class_set : classes_) {
- auto it = class_set.Find(slot);
+ auto it = class_set.find(slot);
if (it != class_set.end()) {
return it->Read();
}
}
- classes_.back().Insert(slot);
+ classes_.back().insert(slot);
return klass;
}
@@ -163,12 +163,12 @@
void ClassTable::CopyWithoutLocks(const ClassTable& source_table) {
if (kIsDebugBuild) {
for (ClassSet& class_set : classes_) {
- CHECK(class_set.Empty());
+ CHECK(class_set.empty());
}
}
for (const ClassSet& class_set : source_table.classes_) {
for (const TableSlot& slot : class_set) {
- classes_.back().Insert(slot);
+ classes_.back().insert(slot);
}
}
}
@@ -187,9 +187,9 @@
DescriptorHashPair pair(descriptor, ComputeModifiedUtf8Hash(descriptor));
WriterMutexLock mu(Thread::Current(), lock_);
for (ClassSet& class_set : classes_) {
- auto it = class_set.Find(pair);
+ auto it = class_set.find(pair);
if (it != class_set.end()) {
- class_set.Erase(it);
+ class_set.erase(it);
return true;
}
}
@@ -268,7 +268,7 @@
// default in case classes were pruned.
for (const ClassSet& class_set : classes_) {
for (const TableSlot& root : class_set) {
- combined.Insert(root);
+ combined.insert(root);
}
}
const size_t ret = combined.WriteToMemory(ptr);