diff --git a/source/graphics/ObjectEntry.cpp b/source/graphics/ObjectEntry.cpp index 4427a4f105..07c320aa7e 100644 --- a/source/graphics/ObjectEntry.cpp +++ b/source/graphics/ObjectEntry.cpp @@ -165,7 +165,7 @@ bool CObjectEntry::BuildVariation(const std::vector >& 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); } } diff --git a/source/graphics/ShaderDefines.cpp b/source/graphics/ShaderDefines.cpp index c403189656..56c437a824 100644 --- a/source/graphics/ShaderDefines.cpp +++ b/source/graphics/ShaderDefines.cpp @@ -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::SItems* CShaderParams::GetInterned(con ENSURE(std::adjacent_find(items.items.begin(), items.items.end(), std::binary_negate(Cmp())) == items.items.end()); shared_ptr 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)); } } diff --git a/source/graphics/ShaderManager.cpp b/source/graphics/ShaderManager.cpp index ccd4e3bd83..8ad36662d4 100644 --- a/source/graphics/ShaderManager.cpp +++ b/source/graphics/ShaderManager.cpp @@ -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()) diff --git a/source/graphics/TerrainTextureEntry.cpp b/source/graphics/TerrainTextureEntry.cpp index 677c126239..f2273d2765 100644 --- a/source/graphics/TerrainTextureEntry.cpp +++ b/source/graphics/TerrainTextureEntry.cpp @@ -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); } } diff --git a/source/lib/sysdep/os/linux/dir_watch_inotify.cpp b/source/lib/sysdep/os/linux/dir_watch_inotify.cpp index 863bf4649f..5cfbd49c33 100644 --- a/source/lib/sysdep/os/linux/dir_watch_inotify.cpp +++ b/source/lib/sysdep/os/linux/dir_watch_inotify.cpp @@ -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; } diff --git a/source/network/NetServer.cpp b/source/network/NetServer.cpp index 0f6b7ebaaa..d5f2204c70 100644 --- a/source/network/NetServer.cpp +++ b/source/network/NetServer.cpp @@ -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() diff --git a/source/network/NetTurnManager.cpp b/source/network/NetTurnManager.cpp index b4664dd7a1..0ba54afbf5 100644 --- a/source/network/NetTurnManager.cpp +++ b/source/network/NetTurnManager.cpp @@ -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) diff --git a/source/ps/CStrIntern.cpp b/source/ps/CStrIntern.cpp index 6692b35afa..dc2361a070 100644 --- a/source/ps/CStrIntern.cpp +++ b/source/ps/CStrIntern.cpp @@ -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 internals(new CStrInternInternals(str, len)); - g_Strings.insert(std::make_pair(internals->data, internals)); + g_Strings.emplace(internals->data, internals); return internals.get(); } diff --git a/source/ps/ConfigDB.cpp b/source/ps/ConfigDB.cpp index 002dcd6550..2d280f2d27 100644 --- a/source/ps/ConfigDB.cpp +++ b/source/ps/ConfigDB.cpp @@ -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; } diff --git a/source/ps/Filesystem.cpp b/source/ps/Filesystem.cpp index b76ab32e4c..79e67cc007 100644 --- a/source/ps/Filesystem.cpp +++ b/source/ps/Filesystem.cpp @@ -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) diff --git a/source/ps/GameSetup/CmdLineArgs.cpp b/source/ps/GameSetup/CmdLineArgs.cpp index 1e1868d68c..2f61839c98 100644 --- a/source/ps/GameSetup/CmdLineArgs.cpp +++ b/source/ps/GameSetup/CmdLineArgs.cpp @@ -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)); } } diff --git a/source/ps/XML/Xeromyces.cpp b/source/ps/XML/Xeromyces.cpp index af8a9ac9ee..28bb104d96 100644 --- a/source/ps/XML/Xeromyces.cpp +++ b/source/ps/XML/Xeromyces.cpp @@ -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::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; } diff --git a/source/renderer/TerrainOverlay.cpp b/source/renderer/TerrainOverlay.cpp index 44f67fbd43..431badc200 100644 --- a/source/renderer/TerrainOverlay.cpp +++ b/source/renderer/TerrainOverlay.cpp @@ -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 > 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). diff --git a/source/scriptinterface/ScriptStats.cpp b/source/scriptinterface/ScriptStats.cpp index 7fbff92b15..a680d00648 100644 --- a/source/scriptinterface/ScriptStats.cpp +++ b/source/scriptinterface/ScriptStats.cpp @@ -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) diff --git a/source/simulation2/components/CCmpAIManager.cpp b/source/simulation2/components/CCmpAIManager.cpp index 6bb85dc637..f33af46d6a 100644 --- a/source/simulation2/components/CCmpAIManager.cpp +++ b/source/simulation2/components/CCmpAIManager.cpp @@ -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++; diff --git a/source/simulation2/components/CCmpUnitRenderer.cpp b/source/simulation2/components/CCmpUnitRenderer.cpp index b948fdb99e..8f39cc8542 100644 --- a/source/simulation2/components/CCmpUnitRenderer.cpp +++ b/source/simulation2/components/CCmpUnitRenderer.cpp @@ -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); } } }; diff --git a/source/simulation2/helpers/Render.cpp b/source/simulation2/helpers/Render.cpp index 07c2beb424..9fedea5fa5 100644 --- a/source/simulation2/helpers/Render.cpp +++ b/source/simulation2/helpers/Render.cpp @@ -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 >& 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); diff --git a/source/simulation2/helpers/Selection.cpp b/source/simulation2/helpers/Selection.cpp index 7e3e8e2907..64634f4ef9 100644 --- a/source/simulation2/helpers/Selection.cpp +++ b/source/simulation2/helpers/Selection.cpp @@ -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 diff --git a/source/simulation2/serialization/SerializeTemplates.h b/source/simulation2/serialization/SerializeTemplates.h index f9ec8c460c..4ac08d7f0b 100644 --- a/source/simulation2/serialization/SerializeTemplates.h +++ b/source/simulation2/serialization/SerializeTemplates.h @@ -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); } } }; diff --git a/source/simulation2/system/ComponentManager.cpp b/source/simulation2/system/ComponentManager.cpp index 52a5203109..1915102420 100644 --- a/source/simulation2/system/ComponentManager.cpp +++ b/source/simulation2/system/ComponentManager.cpp @@ -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())); - 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())); - 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& 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);