// new result of the StringFactory. Use the verifier to find this set of registers.
ArtMethod* method = shadow_frame.GetMethod();
MethodReference method_ref = method->ToMethodReference();
- SafeMap<uint32_t, std::set<uint32_t>> string_init_map;
- SafeMap<uint32_t, std::set<uint32_t>>* string_init_map_ptr;
+ SafeMap<uint32_t, std::set<uint32_t>>* string_init_map_ptr = nullptr;
MethodRefToStringInitRegMap& method_to_string_init_map = Runtime::Current()->GetStringInitMap();
- MethodRefToStringInitRegMap::iterator it;
{
MutexLock mu(self, *Locks::interpreter_string_init_map_lock_);
- it = method_to_string_init_map.find(method_ref);
- }
- if (it == method_to_string_init_map.end()) {
- string_init_map = std::move(verifier::MethodVerifier::FindStringInitMap(method));
- {
- MutexLock mu(self, *Locks::interpreter_string_init_map_lock_);
- method_to_string_init_map.Overwrite(method_ref, string_init_map);
+ auto it = method_to_string_init_map.find(method_ref);
+ if (it != method_to_string_init_map.end()) {
+ string_init_map_ptr = &it->second;
}
- string_init_map_ptr = &string_init_map;
- } else {
+ }
+ if (string_init_map_ptr == nullptr) {
+ SafeMap<uint32_t, std::set<uint32_t>> string_init_map =
+ verifier::MethodVerifier::FindStringInitMap(method);
+ MutexLock mu(self, *Locks::interpreter_string_init_map_lock_);
+ auto it = method_to_string_init_map.Overwrite(method_ref, string_init_map);
string_init_map_ptr = &it->second;
}
if (string_init_map_ptr->size() != 0) {
// Used to insert a new mapping or overwrite an existing mapping. Note that if the value type
// of this container is a pointer, any overwritten pointer will be lost and if this container
// was the owner, you have a leak.
- void Overwrite(const K& k, const V& v) {
+ iterator Overwrite(const K& k, const V& v) {
std::pair<iterator, bool> result = map_.insert(std::make_pair(k, v));
if (!result.second) {
// Already there - update the value for the existing key
result.first->second = v;
}
+ return result.first;
}
bool Equals(const Self& rhs) const {