From 92aa7222852ac9dba38246faec0be6ec80425d2c Mon Sep 17 00:00:00 2001 From: Henning Baldersheim Date: Wed, 13 Dec 2017 23:02:15 +0100 Subject: Exception to construction should not create an empty entry in the map. --- .../src/vespa/searchvisitor/searchenvironment.cpp | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) (limited to 'streamingvisitors') diff --git a/streamingvisitors/src/vespa/searchvisitor/searchenvironment.cpp b/streamingvisitors/src/vespa/searchvisitor/searchenvironment.cpp index 64c2c9a6429..7ebb71f1855 100644 --- a/streamingvisitors/src/vespa/searchvisitor/searchenvironment.cpp +++ b/streamingvisitors/src/vespa/searchvisitor/searchenvironment.cpp @@ -15,9 +15,7 @@ __thread SearchEnvironment::EnvMap * SearchEnvironment::_localEnvMap=0; SearchEnvironment::Env::Env(const vespalib::string & muffens, const config::ConfigUri & configUri, Fast_NormalizeWordFolder & wf) : _configId(configUri.getConfigId()), - _configurer(config::SimpleConfigRetriever::UP( - new config::SimpleConfigRetriever(createKeySet(configUri.getConfigId()), configUri.getContext())), - this), + _configurer(std::make_unique(createKeySet(configUri.getConfigId()), configUri.getContext()), this), _vsmAdapter(new VSMAdapter(muffens, _configId, wf)), _rankManager(new RankManager(_vsmAdapter.get())) { @@ -63,13 +61,15 @@ SearchEnvironment::~SearchEnvironment() _threadLocals.clear(); } -SearchEnvironment::Env & SearchEnvironment::getEnv(const vespalib::string & searchCluster) +SearchEnvironment::Env & +SearchEnvironment::getEnv(const vespalib::string & searchCluster) { config::ConfigUri searchClusterUri(_configUri.createWithNewId(searchCluster)); if (_localEnvMap == NULL) { - _localEnvMap = new EnvMap; + EnvMapUP envMap = std::make_unique(); + _localEnvMap = envMap.get(); vespalib::LockGuard guard(_lock); - _threadLocals.push_back(EnvMapUP(_localEnvMap)); + _threadLocals.emplace_back(std::move(envMap)); } EnvMap::iterator localFound = _localEnvMap->find(searchCluster); if (localFound == _localEnvMap->end()) { @@ -77,7 +77,8 @@ SearchEnvironment::Env & SearchEnvironment::getEnv(const vespalib::string & sear EnvMap::iterator found = _envMap.find(searchCluster); if (found == _envMap.end()) { LOG(debug, "Init VSMAdapter with config id = '%s'", searchCluster.c_str()); - _envMap[searchCluster].reset(new Env("*", searchClusterUri, _wordFolder)); + Env::SP env = std::make_shared("*", searchClusterUri, _wordFolder); + _envMap[searchCluster] = std::move(env); found = _envMap.find(searchCluster); } _localEnvMap->insert(*found); -- cgit v1.2.3