mirror of
https://github.com/cocos/cocos4.git
synced 2026-11-20 23:52:40 +08:00
use Map::emplace() to avoid creating pair object (#12152)
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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();
|
||||
|
||||
Reference in New Issue
Block a user