diff options
author | 2022-09-22 09:18:11 +0000 | |
---|---|---|
committer | 2022-09-22 13:05:25 +0000 | |
commit | 78ed10851008831fe43c87f4334ca98be4f97c98 (patch) | |
tree | 4531b142d47eaf335e92342955a1e32ea080bdd5 | |
parent | fed6c04fd8629ada49d169b6cca4e0742ea3b8d5 (diff) |
Specialize `DefaultEmptyFn` for `std::string`.
The default implementation for `IsEmpty()` turns out
to be very slow.
Test: m test-art-host-gtest
Test: testrunner.py --host --optimizing
Bug: 181943478
Change-Id: I0cbeb4ff942a9a0ad0c6130eec7cc096cf3d564e
-rw-r--r-- | libartbase/base/hash_set.h | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/libartbase/base/hash_set.h b/libartbase/base/hash_set.h index c4af1b6668..3f3c8f2494 100644 --- a/libartbase/base/hash_set.h +++ b/libartbase/base/hash_set.h @@ -139,6 +139,17 @@ class DefaultEmptyFn<T*> { } }; +template <> +class DefaultEmptyFn<std::string> { + public: + void MakeEmpty(std::string& item) const { + item = std::string(); + } + bool IsEmpty(const std::string& item) const { + return item.empty(); + } +}; + template <class T> using DefaultHashFn = std::conditional_t<std::is_same_v<T, std::string>, DataHash, std::hash<T>>; |