summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authornikolay serdjuk <nikolay.y.serdjuk@intel.com>2015-04-17 19:27:56 +0600
committernikolay serdjuk <nikolay.y.serdjuk@intel.com>2015-04-21 10:07:32 +0600
commita446d8671b30438003472c1de1363fc0699a7f7b (patch)
treecf018dd565628dff7ee10c44b023af42d2d9983c
parent2fb1639a4bd836f6426cc0d4b8d21c59d2648527 (diff)
downloadart-a446d8671b30438003472c1de1363fc0699a7f7b.zip
art-a446d8671b30438003472c1de1363fc0699a7f7b.tar.gz
art-a446d8671b30438003472c1de1363fc0699a7f7b.tar.bz2
Improve performance of HashSet
Don't pollute hash table with duplicates. Check for existing value before storing a new one. Change-Id: If43ea5e98a3f3ba187b8dea66f3712ec62bd3f60 Signed-off-by: nikolay serdjuk <nikolay.y.serdjuk@intel.com>
-rw-r--r--runtime/intern_table.cc10
1 files changed, 5 insertions, 5 deletions
diff --git a/runtime/intern_table.cc b/runtime/intern_table.cc
index 1f1f9e8..4c5fc81 100644
--- a/runtime/intern_table.cc
+++ b/runtime/intern_table.cc
@@ -236,11 +236,6 @@ mirror::String* InternTable::Insert(mirror::String* s, bool is_strong) {
if (strong != nullptr) {
return strong;
}
- // Check the image for a match.
- mirror::String* image = LookupStringFromImage(s);
- if (image != nullptr) {
- return is_strong ? InsertStrong(image) : InsertWeak(image);
- }
// There is no match in the strong table, check the weak table.
mirror::String* weak = LookupWeak(s);
if (weak != nullptr) {
@@ -251,6 +246,11 @@ mirror::String* InternTable::Insert(mirror::String* s, bool is_strong) {
}
return weak;
}
+ // Check the image for a match.
+ mirror::String* image = LookupStringFromImage(s);
+ if (image != nullptr) {
+ return is_strong ? InsertStrong(image) : InsertWeak(image);
+ }
// No match in the strong table or the weak table. Insert into the strong / weak table.
return is_strong ? InsertStrong(s) : InsertWeak(s);
}