diff options
| author | 2014-05-23 10:50:39 +0000 | |
|---|---|---|
| committer | 2014-05-23 10:50:39 +0000 | |
| commit | 831593646f07a960010c80df98b7afa59b57dfb5 (patch) | |
| tree | ccad69e010e8af0b179bb91581fdd7eae703b0e2 | |
| parent | 19cdfa15be3c7ddf9c14ae3d0b7d94f9f37ea503 (diff) | |
| parent | 53dc70cc824fa71c237015de2bebb2da6b462b5d (diff) | |
Merge "Fix InternTable::Lookup()/Remove() for hash code collisions."
| -rw-r--r-- | runtime/intern_table.cc | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/runtime/intern_table.cc b/runtime/intern_table.cc index 817d1045cf..339eb36178 100644 --- a/runtime/intern_table.cc +++ b/runtime/intern_table.cc @@ -84,7 +84,8 @@ void InternTable::VisitRoots(RootCallback* callback, void* arg, VisitRootFlags f mirror::String* InternTable::Lookup(Table& table, mirror::String* s, int32_t hash_code) { Locks::intern_table_lock_->AssertHeld(Thread::Current()); - for (auto it = table.find(hash_code), end = table.end(); it != end; ++it) { + for (auto it = table.lower_bound(hash_code), end = table.end(); + it != end && it->first == hash_code; ++it) { mirror::String* existing_string = it->second; if (existing_string->Equals(s)) { return existing_string; @@ -123,7 +124,8 @@ void InternTable::RemoveWeak(mirror::String* s, int32_t hash_code) { } void InternTable::Remove(Table& table, mirror::String* s, int32_t hash_code) { - for (auto it = table.find(hash_code), end = table.end(); it != end; ++it) { + for (auto it = table.lower_bound(hash_code), end = table.end(); + it != end && it->first == hash_code; ++it) { if (it->second == s) { table.erase(it); return; |