Use in-place construction.

This was SVN commit r16894.
This commit is contained in:
leper 2015-07-29 23:44:17 +00:00
parent c5eb9b7bb7
commit 8bfe16cac8
20 changed files with 40 additions and 40 deletions

View File

@ -165,7 +165,7 @@ bool CObjectEntry::BuildVariation(const std::vector<std::set<CStr> >& selections
{
CSkeletonAnim* anim = model->BuildAnimation(it->second.m_FileName, name, it->second.m_Speed, it->second.m_ActionPos, it->second.m_ActionPos2, it->second.m_SoundPos);
if (anim)
m_Animations.insert(std::make_pair(name, anim));
m_Animations.emplace(std::move(name), anim);
}
}

View File

@ -1,4 +1,4 @@
/* Copyright (C) 2012 Wildfire Games.
/* Copyright (C) 2015 Wildfire Games.
* This file is part of 0 A.D.
*
* 0 A.D. is free software: you can redistribute it and/or modify
@ -94,7 +94,7 @@ typename CShaderParams<value_t>::SItems* CShaderParams<value_t>::GetInterned(con
ENSURE(std::adjacent_find(items.items.begin(), items.items.end(), std::binary_negate<Cmp>(Cmp())) == items.items.end());
shared_ptr<SItems> ptr(new SItems(items));
s_InternedItems.insert(std::make_pair(items, ptr));
s_InternedItems.emplace(items, ptr);
return ptr.get();
}
@ -245,15 +245,15 @@ void CShaderRenderQueries::Add(const char* name)
{
if (name == CStr("sim_time"))
{
m_Items.push_back(std::make_pair(RQUERY_TIME, CStrIntern(name)));
m_Items.emplace_back(RQUERY_TIME, CStrIntern(name));
}
else if (name == CStr("water_tex"))
{
m_Items.push_back(std::make_pair(RQUERY_WATER_TEX, CStrIntern(name)));
m_Items.emplace_back(RQUERY_WATER_TEX, CStrIntern(name));
}
else if (name == CStr("sky_cube"))
{
m_Items.push_back(std::make_pair(RQUERY_SKY_CUBE, CStrIntern(name)));
m_Items.emplace_back(RQUERY_SKY_CUBE, CStrIntern(name));
}
}

View File

@ -488,7 +488,7 @@ bool CShaderManager::NewEffect(const char* name, const CShaderDefines& baseDefin
}
if (isUsable)
usableTechs.push_back(std::make_pair(Technique, preference));
usableTechs.emplace_back(Technique, preference);
}
if (usableTechs.empty())

View File

@ -99,7 +99,7 @@ CTerrainTextureEntry::CTerrainTextureEntry(CTerrainPropertiesPtr properties, con
else if (se.Name == at_name)
name = se.Value;
}
samplers.push_back(make_pair(name, path));
samplers.emplace_back(name, path);
}
}

View File

@ -1,4 +1,4 @@
/* Copyright (c) 2014 Wildfire Games
/* Copyright (c) 2015 Wildfire Games
*
* Permission is hereby granted, free of charge, to any person obtaining
* a copy of this software and associated documentation files (the
@ -216,7 +216,7 @@ Status dir_watch_Add(const OsPath& path, PDirWatch& dirWatch)
dirWatch.swap(tmpDirWatch);
dirWatch->path = path;
dirWatch->reqnum = wd;
g_paths.insert(std::make_pair(wd, dirWatch));
g_paths.emplace(wd, dirWatch);
return INFO::OK;
}

View File

@ -1138,13 +1138,13 @@ bool CNetServer::SetupConnection()
void CNetServer::AssignPlayer(int playerID, const CStr& guid)
{
CScopeLock lock(m_Worker->m_WorkerMutex);
m_Worker->m_AssignPlayerQueue.push_back(std::make_pair(playerID, guid));
m_Worker->m_AssignPlayerQueue.emplace_back(playerID, guid);
}
void CNetServer::SetPlayerReady(const CStr& guid, int ready)
{
CScopeLock lock(m_Worker->m_WorkerMutex);
m_Worker->m_PlayerReadyQueue.push_back(std::make_pair(guid, ready));
m_Worker->m_PlayerReadyQueue.emplace_back(guid, ready);
}
void CNetServer::ClearAllPlayerReady()

View File

@ -491,7 +491,7 @@ CNetReplayTurnManager::CNetReplayTurnManager(CSimulation2& simulation, IReplayLo
void CNetReplayTurnManager::StoreReplayCommand(u32 turn, int player, const std::string& command)
{
// Using the pair we make sure that commands per turn will be processed in the correct order
m_ReplayCommands[turn].push_back(std::make_pair(player, command));
m_ReplayCommands[turn].emplace_back(player, command);
}
void CNetReplayTurnManager::StoreReplayHash(u32 turn, const std::string& hash, bool quick)

View File

@ -1,4 +1,4 @@
/* Copyright (C) 2012 Wildfire Games.
/* Copyright (C) 2015 Wildfire Games.
* This file is part of 0 A.D.
*
* 0 A.D. is free software: you can redistribute it and/or modify
@ -113,7 +113,7 @@ static CStrInternInternals* GetString(const char* str, size_t len)
return it->second.get();
shared_ptr<CStrInternInternals> internals(new CStrInternInternals(str, len));
g_Strings.insert(std::make_pair(internals->data, internals));
g_Strings.emplace(internals->data, internals);
return internals.get();
}

View File

@ -184,7 +184,7 @@ void CConfigDB::SetValueString(EConfigNamespace ns, const CStr& name, const CStr
CScopeLock s(&cfgdb_mutex);
TConfigMap::iterator it = m_Map[ns].find(name);
if (it == m_Map[ns].end())
it = m_Map[ns].insert(m_Map[ns].begin(), make_pair(name, CConfigValueSet(1)));
it = m_Map[ns].emplace_hint(m_Map[ns].begin(), name, CConfigValueSet(1));
it->second[0] = value;
}

View File

@ -43,7 +43,7 @@ bool VfsDirectoryExists(const VfsPath& pathname)
void RegisterFileReloadFunc(FileReloadFunc func, void* obj)
{
g_ReloadFuncs.push_back(std::make_pair(func, obj));
g_ReloadFuncs.emplace_back(func, obj);
}
void UnregisterFileReloadFunc(FileReloadFunc func, void* obj)

View File

@ -1,4 +1,4 @@
/* Copyright (C) 2009 Wildfire Games.
/* Copyright (C) 2015 Wildfire Games.
* This file is part of 0 A.D.
*
* 0 A.D. is free software: you can redistribute it and/or modify
@ -51,7 +51,7 @@ CmdLineArgs::CmdLineArgs(int argc, const char* argv[])
name = CStr(argv[i]+1);
}
m_Args.push_back(make_pair(name, value));
m_Args.emplace_back(std::move(name), std::move(value));
}
}

View File

@ -56,7 +56,7 @@ void CXeromyces::Startup()
xmlInitParser();
xmlSetStructuredErrorFunc(NULL, &errorHandler);
CScopeLock lock(g_ValidatorCacheLock);
g_ValidatorCache.insert(std::make_pair("", RelaxNGValidator()));
g_ValidatorCache.emplace(std::string(), RelaxNGValidator());
g_XeromycesStarted = true;
}
@ -86,7 +86,7 @@ bool CXeromyces::AddValidator(const PIVFS& vfs, const std::string& name, const V
std::map<const std::string, RelaxNGValidator>::iterator it = g_ValidatorCache.find(name);
if (it != g_ValidatorCache.end())
g_ValidatorCache.erase(it);
g_ValidatorCache.insert(std::make_pair(name, validator));
g_ValidatorCache.emplace(name, validator);
}
return true;
}

View File

@ -1,4 +1,4 @@
/* Copyright (C) 2012 Wildfire Games.
/* Copyright (C) 2015 Wildfire Games.
* This file is part of 0 A.D.
*
* 0 A.D. is free software: you can redistribute it and/or modify
@ -66,7 +66,7 @@ static std::vector<std::pair<ITerrainOverlay*, int> > g_TerrainOverlayList;
ITerrainOverlay::ITerrainOverlay(int priority)
{
// Add to global list of overlays
g_TerrainOverlayList.push_back(std::make_pair(this, priority));
g_TerrainOverlayList.emplace_back(this, priority);
// Sort by overlays by priority. Do stable sort so that adding/removing
// overlays doesn't randomly disturb all the existing ones (which would
// be noticeable if they have the same priority and overlap).

View File

@ -1,4 +1,4 @@
/* Copyright (C) 2010 Wildfire Games.
/* Copyright (C) 2015 Wildfire Games.
* This file is part of 0 A.D.
*
* 0 A.D. is free software: you can redistribute it and/or modify
@ -38,7 +38,7 @@ CScriptStatsTable::CScriptStatsTable()
void CScriptStatsTable::Add(const ScriptInterface* scriptInterface, const std::string& title)
{
m_ScriptInterfaces.push_back(std::make_pair(scriptInterface, title));
m_ScriptInterfaces.emplace_back(scriptInterface, title);
}
void CScriptStatsTable::Remove(const ScriptInterface* scriptInterface)

View File

@ -1145,7 +1145,7 @@ private:
const CParamNode* node = cmpTemplateManager->GetTemplateWithoutValidation(m_TemplateNames[m_TemplateLoadedIdx]);
if (node)
m_Templates.push_back(std::make_pair(m_TemplateNames[m_TemplateLoadedIdx], node));
m_Templates.emplace_back(m_TemplateNames[m_TemplateLoadedIdx], node);
m_TemplateLoadedIdx++;

View File

@ -1,4 +1,4 @@
/* Copyright (C) 2014 Wildfire Games.
/* Copyright (C) 2015 Wildfire Games.
* This file is part of 0 A.D.
*
* 0 A.D. is free software: you can redistribute it and/or modify
@ -319,7 +319,7 @@ public:
center = selectionBox.m_Center;
}
outEntities.push_back(std::make_pair(unit.entity, center));
outEntities.emplace_back(unit.entity, center);
}
}
};

View File

@ -1,4 +1,4 @@
/* Copyright (C) 2012 Wildfire Games.
/* Copyright (C) 2015 Wildfire Games.
* This file is part of 0 A.D.
*
* 0 A.D. is free software: you can redistribute it and/or modify
@ -151,10 +151,10 @@ static void SplitLine(std::vector<std::pair<float, float> >& coords, float x1, f
float yPieceLength = (y1 - y2) / (float)pieces;
for (size_t i = 1; i <= (pieces - 1); ++i)
{
coords.push_back(std::make_pair(x1 - (xPieceLength * (float)i), y1 - (yPieceLength * (float)i)));
coords.emplace_back(x1 - (xPieceLength * (float)i), y1 - (yPieceLength * (float)i));
}
}
coords.push_back(std::make_pair(x2, y2));
coords.emplace_back(x2, y2);
}
void SimRender::ConstructSquareOnGround(const CSimContext& context, float x, float z, float w, float h, float a,
@ -182,7 +182,7 @@ void SimRender::ConstructSquareOnGround(const CSimContext& context, float x, flo
// Add the first vertex, since SplitLine will be adding only the second end-point of the each line to
// the coordinates list. We don't have to worry about the other lines, since the end-point of one line
// will be the starting point of the next
coords.push_back(std::make_pair(x - w/2*c + h/2*s, z + w/2*s + h/2*c));
coords.emplace_back(x - w/2*c + h/2*s, z + w/2*s + h/2*c);
SplitLine(coords, x - w/2*c + h/2*s, z + w/2*s + h/2*c, x - w/2*c - h/2*s, z + w/2*s - h/2*c);
SplitLine(coords, x - w/2*c - h/2*s, z + w/2*s - h/2*c, x + w/2*c - h/2*s, z - w/2*s - h/2*c);

View File

@ -60,7 +60,7 @@ entity_id_t EntitySelection::PickEntityAtPoint(CSimulation2& simulation, const C
const CVector3D center = entities[i].second;
CVector3D closest = origin + dir * (center - origin).Dot(dir);
dist2 = (closest - center).LengthSquared();
hits.push_back(std::make_pair(dist2, entities[i].first));
hits.emplace_back(dist2, entities[i].first);
}
// Sort hits by distance

View File

@ -94,7 +94,7 @@ struct SerializeMap
V v;
KS()(deserialize, "key", k);
VS()(deserialize, "value", v);
value.insert(std::make_pair(k, v));
value.emplace(k, v);
}
}
@ -112,7 +112,7 @@ struct SerializeMap
V v;
KS()(deserialize, "key", k);
VS()(deserialize, "value", v, context);
value.insert(std::make_pair(k, v));
value.emplace(k, v);
}
}
};

View File

@ -544,7 +544,7 @@ void CComponentManager::RegisterComponentType(InterfaceId iid, ComponentTypeId c
const char* name, const std::string& schema)
{
ComponentType c(CT_Native, iid, alloc, dealloc, name, schema, std::move(DefPersistentRooted<JS::Value>()));
m_ComponentTypesById.insert(std::make_pair(cid, std::move(c)));
m_ComponentTypesById.emplace(cid, std::move(c));
m_ComponentTypeIdsByName[name] = cid;
}
@ -552,7 +552,7 @@ void CComponentManager::RegisterComponentTypeScriptWrapper(InterfaceId iid, Comp
DeallocFunc dealloc, const char* name, const std::string& schema)
{
ComponentType c(CT_ScriptWrapper, iid, alloc, dealloc, name, schema, std::move(DefPersistentRooted<JS::Value>()));
m_ComponentTypesById.insert(std::make_pair(cid, std::move(c)));
m_ComponentTypesById.emplace(cid, std::move(c));
m_ComponentTypeIdsByName[name] = cid;
// TODO: merge with RegisterComponentType
}
@ -778,8 +778,8 @@ IComponent* CComponentManager::ConstructComponent(CEntityHandle ent, ComponentTy
component->SetSimContext(m_SimContext);
// Store a reference to the new component
emap1.insert(std::make_pair(ent.GetId(), component));
emap2.insert(std::make_pair(ent.GetId(), component));
emap1.emplace(ent.GetId(), component);
emap2.emplace(ent.GetId(), component);
// TODO: We need to more careful about this - if an entity is constructed by a component
// while we're iterating over all components, this will invalidate the iterators and everything
// will break.
@ -801,7 +801,7 @@ void CComponentManager::AddMockComponent(CEntityHandle ent, InterfaceId iid, ICo
boost::unordered_map<entity_id_t, IComponent*>& emap1 = m_ComponentsByInterface.at(iid);
if (emap1.find(ent.GetId()) != emap1.end())
debug_warn(L"Multiple components for interface");
emap1.insert(std::make_pair(ent.GetId(), &component));
emap1.emplace(ent.GetId(), &component);
SEntityComponentCache* cache = ent.GetComponentCache();
ENSURE(cache != NULL && iid < (int)cache->numInterfaces && cache->interfaces[iid] == NULL);