git.iko.soy/rowtype-yoga/purescript-native
on golang help sign in
C++: a little extra map key optimization
commit1e55cc35e8b998afb8966935d426e895460df58c authorAndy Arvanitis <andyarvanitis@gmail.com> dateMon 18 Jan 2016, 19:15 (11 years ago) parentc7392d6
1 file changed+9−2
pcc/include/purescript.cc+9−2
pcc/include/purescript.cc+9−2
@@ -257,8 +257,15 @@ auto any::extractValue(const any& a) -> const any& {
257257auto any::operator[](const char rhs[]) const -> const any& {
258258 const any& val = extractValue(*this);
259259 assert(val.type == Type::Map);
260− for (any::map::const_iterator it = val.m->begin(), end = val.m->end(); it != end; ++it) {
261− if (it->first == rhs || strcmp(it->first, rhs) == 0) {
260+ const any::map::const_iterator begin = val.m->begin();
261+ const any::map::const_iterator end = val.m->end();
262+ for (any::map::const_iterator it = begin; it != end; ++it) {
263+ if (it->first == rhs) {
264+ return it->second;
265+ }
266+ }
267+ for (any::map::const_iterator it = begin; it != end; ++it) {
268+ if (strcmp(it->first, rhs) == 0) {
262269 return it->second;
263270 }
264271 }