Avoid coercing to key type in SafeMap
SafeMap would immediately coerce the inputs to several of its functions
to the key type. This could cause the inliner to fail to perform some
optimization in some circumstances. By passing down the input
unaltered we should get better optimization.
Bug: 135202227
Test: ./test.py --host
Test: atest CtsJvmtiRunTest1941HostTestCases -- --abi armeabi-v7a
Test: atest CtsJvmtiRunTest1941HostTestCases -- --abi arm64-v8a
Change-Id: I0d8c9f2cc43ef28bf2d043f6a96eadc9aa701cf4
diff --git a/libartbase/base/safe_map.h b/libartbase/base/safe_map.h
index a4d8459..f57a2aa 100644
--- a/libartbase/base/safe_map.h
+++ b/libartbase/base/safe_map.h
@@ -70,18 +70,22 @@
void swap(Self& other) { map_.swap(other.map_); }
void clear() { map_.clear(); }
iterator erase(iterator it) { return map_.erase(it); }
- size_type erase(const K& k) { return map_.erase(k); }
+ template<typename Kv> size_type erase(const Kv& k) { return map_.erase(k); }
- iterator find(const K& k) { return map_.find(k); }
- const_iterator find(const K& k) const { return map_.find(k); }
+ template<typename Kv> iterator find(const Kv& k) { return map_.find(k); }
+ template<typename Kv> const_iterator find(const Kv& k) const { return map_.find(k); }
- iterator lower_bound(const K& k) { return map_.lower_bound(k); }
- const_iterator lower_bound(const K& k) const { return map_.lower_bound(k); }
+ template<typename Kv> iterator lower_bound(const Kv& k) { return map_.lower_bound(k); }
+ template<typename Kv> const_iterator lower_bound(const Kv& k) const {
+ return map_.lower_bound(k);
+ }
- iterator upper_bound(const K& k) { return map_.upper_bound(k); }
- const_iterator upper_bound(const K& k) const { return map_.upper_bound(k); }
+ template<typename Kv> iterator upper_bound(const Kv& k) { return map_.upper_bound(k); }
+ template<typename Kv> const_iterator upper_bound(const Kv& k) const {
+ return map_.upper_bound(k);
+ }
- size_type count(const K& k) const { return map_.count(k); }
+ template<typename Kv> size_type count(const Kv& k) const { return map_.count(k); }
// Note that unlike std::map's operator[], this doesn't return a reference to the value.
V Get(const K& k) const {