use Map::emplace() to avoid creating pair object (#12152)

This commit is contained in:
minggo
2022-07-29 09:47:55 +08:00
committed by GitHub
parent ce173cf0dc
commit 063e049d66
3 changed files with 4 additions and 4 deletions
+1 -1
View File
@@ -96,7 +96,7 @@ static void localDownloaderCreateTask(const ccstd::string &url, const std::funct
ss << "jsb_loadimage_" << (gLocalDownloaderTaskId++);
ccstd::string key = ss.str();
auto task = localDownloader()->createDataTask(url, key);
gLocalDownloaderHandlers.emplace(std::make_pair(task->identifier, callback));
gLocalDownloaderHandlers.emplace(task->identifier, callback);
}
bool jsb_set_extend_property(const char *ns, const char *clsName) { // NOLINT
+2 -2
View File
@@ -675,7 +675,7 @@ ccstd::string FileUtils::fullPathForFilename(const ccstd::string &filename) cons
if (!fullpath.empty()) {
// Using the filename passed in as key.
_fullPathCache.insert(std::make_pair(filename, fullpath));
_fullPathCache.emplace(filename, fullpath);
return fullpath;
}
}
@@ -812,7 +812,7 @@ bool FileUtils::isDirectoryExist(const ccstd::string &dirPath) const {
// searchPath + file_path
fullpath = fullPathForFilename(searchIt + dirPath);
if (isDirectoryExistInternal(fullpath)) {
_fullPathCache.insert(std::make_pair(dirPath, fullpath));
_fullPathCache.emplace(dirPath, fullpath);
return true;
}
}
+1 -1
View File
@@ -410,7 +410,7 @@ CCMTLGPUPipelineState *getClearRenderPassPipelineState(CCMTLDevice *device, Rend
pipelineInfo.depthStencilState = dsState;
PipelineState *pipelineState = device->createPipelineState(std::move(pipelineInfo));
pipelineMap.emplace(std::make_pair(curPass->getHash(), pipelineState));
pipelineMap.emplace(curPass->getHash(), pipelineState);
((CCMTLPipelineState *)pipelineState)->check();
delete pipelineInfo.shader;
return static_cast<CCMTLPipelineState *>(pipelineState)->getGPUPipelineState();