diff options
author | Leyla Farazha <leyla@lindenlab.com> | 2011-09-23 16:39:09 -0700 |
---|---|---|
committer | Leyla Farazha <leyla@lindenlab.com> | 2011-09-23 16:39:09 -0700 |
commit | 80bb16b36a3bf43514ee0f918dd6d97cbbc1e49f (patch) | |
tree | f05d780fb077be7460bd6a38c90fcd900fbf6974 /indra/llcommon/llinstancetracker.cpp | |
parent | 74d9663ff6444899bd5eedd29da197746a3ae226 (diff) | |
parent | e42a9ec70c0e5fc98282c98358039445d0d68b84 (diff) |
merge
Diffstat (limited to 'indra/llcommon/llinstancetracker.cpp')
-rw-r--r-- | indra/llcommon/llinstancetracker.cpp | 19 |
1 files changed, 10 insertions, 9 deletions
diff --git a/indra/llcommon/llinstancetracker.cpp b/indra/llcommon/llinstancetracker.cpp index f576204511..5dc3ea5d7b 100644 --- a/indra/llcommon/llinstancetracker.cpp +++ b/indra/llcommon/llinstancetracker.cpp @@ -35,14 +35,15 @@ //static void * & LLInstanceTrackerBase::getInstances(std::type_info const & info) { - static std::map<std::string, void *> instances; + typedef std::map<std::string, void *> InstancesMap; + static InstancesMap instances; - std::string k = info.name(); - if(instances.find(k) == instances.end()) - { - instances[k] = NULL; - } - - return instances[k]; + // std::map::insert() is just what we want here. You attempt to insert a + // (key, value) pair. If the specified key doesn't yet exist, it inserts + // the pair and returns a std::pair of (iterator, true). If the specified + // key DOES exist, insert() simply returns (iterator, false). One lookup + // handles both cases. + return instances.insert(InstancesMap::value_type(info.name(), + InstancesMap::mapped_type())) + .first->second; } - |