diff options
author | Jason Carey <jcarey@argv.me> | 2015-10-06 20:30:35 -0400 |
---|---|---|
committer | Jason Carey <jcarey@argv.me> | 2015-10-06 20:30:35 -0400 |
commit | eebc4b80fd11fe4023700c598e72959533cd77af (patch) | |
tree | 584b5d6176eb7e16e2e19746116b4159781df6e4 /src/mongo/scripting | |
parent | 13613424af1ed48c7105651176136f4aef22a675 (diff) | |
download | mongo-eebc4b80fd11fe4023700c598e72959533cd77af.tar.gz |
SERVER-19977 Switch JS BsonHolder to use StringMap
Using StringMap over std::set<std::string> when checking for removed
saves a bunch of string creation.
Diffstat (limited to 'src/mongo/scripting')
-rw-r--r-- | src/mongo/scripting/mozjs/bson.cpp | 8 |
1 files changed, 5 insertions, 3 deletions
diff --git a/src/mongo/scripting/mozjs/bson.cpp b/src/mongo/scripting/mozjs/bson.cpp index 9f0a6125d22..0cb60fb6117 100644 --- a/src/mongo/scripting/mozjs/bson.cpp +++ b/src/mongo/scripting/mozjs/bson.cpp @@ -39,6 +39,7 @@ #include "mongo/scripting/mozjs/objectwrapper.h" #include "mongo/scripting/mozjs/valuereader.h" #include "mongo/scripting/mozjs/valuewriter.h" +#include "mongo/util/string_map.h" namespace mongo { namespace mozjs { @@ -87,7 +88,7 @@ struct BSONHolder { bool _resolved; bool _readOnly; bool _altered; - std::set<std::string> _removed; + StringMap<bool> _removed; }; BSONHolder* getValidHolder(JSContext* cx, JSObject* obj) { @@ -135,7 +136,7 @@ void BSONInfo::enumerate(JSContext* cx, JS::HandleObject obj, JS::AutoIdVector& // TODO: when we get heterogenous set lookup, switch to StringData // rather than involving the temporary string - if (holder->_removed.count(e.fieldName())) + if (holder->_removed.find(e.fieldName()) != holder->_removed.end()) continue; ValueReader(cx, &val).fromStringData(e.fieldNameStringData()); @@ -178,7 +179,8 @@ void BSONInfo::delProperty(JSContext* cx, JS::HandleObject obj, JS::HandleId id, holder->_altered = true; - holder->_removed.insert(IdWrapper(cx, id).toString()); + JSStringWrapper jsstr; + holder->_removed[IdWrapper(cx, id).toStringData(&jsstr)] = true; } *succeeded = true; |