From a567111400ff7ebf93fbd58203b04f417d05be7c Mon Sep 17 00:00:00 2001 From: bzzt Date: Wed, 20 Feb 2019 13:37:00 +0000 Subject: [PATCH] Use emplace instead of find-assign --- components/nifosg/nifloader.cpp | 4 +--- components/sceneutil/visitor.cpp | 5 +---- 2 files changed, 2 insertions(+), 7 deletions(-) diff --git a/components/nifosg/nifloader.cpp b/components/nifosg/nifloader.cpp index eef678b36d..a1aa74cab9 100644 --- a/components/nifosg/nifloader.cpp +++ b/components/nifosg/nifloader.cpp @@ -244,10 +244,8 @@ namespace NifOsg osg::ref_ptr callback(new NifOsg::KeyframeController(key->data.getPtr())); callback->setFunction(std::shared_ptr(new NifOsg::ControllerFunction(key))); - if (target.mKeyframeControllers.find(strdata->string) != target.mKeyframeControllers.end()) + if (!target.mKeyframeControllers.emplace(strdata->string, callback).second) Log(Debug::Verbose) << "Controller " << strdata->string << " present more than once in " << nif->getFilename() << ", ignoring later version"; - else - target.mKeyframeControllers[strdata->string] = callback; } } diff --git a/components/sceneutil/visitor.cpp b/components/sceneutil/visitor.cpp index 3c3559a083..876ea920fa 100644 --- a/components/sceneutil/visitor.cpp +++ b/components/sceneutil/visitor.cpp @@ -61,10 +61,7 @@ namespace SceneUtil { // Take transformation for first found node in file const std::string nodeName = Misc::StringUtils::lowerCase(trans.getName()); - if (mMap.find(nodeName) == mMap.end()) - { - mMap[nodeName] = &trans; - } + mMap.emplace(nodeName, &trans); traverse(trans); }