From 063e049d66b67fced2393112c7fd80da370fa673 Mon Sep 17 00:00:00 2001 From: minggo Date: Fri, 29 Jul 2022 09:47:55 +0800 Subject: [PATCH] use Map::emplace() to avoid creating pair object (#12152) --- native/cocos/bindings/manual/jsb_global.cpp | 2 +- native/cocos/platform/FileUtils.cpp | 4 ++-- native/cocos/renderer/gfx-metal/MTLUtils.mm | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/native/cocos/bindings/manual/jsb_global.cpp b/native/cocos/bindings/manual/jsb_global.cpp index c6d4a207af..1de97edfa2 100644 --- a/native/cocos/bindings/manual/jsb_global.cpp +++ b/native/cocos/bindings/manual/jsb_global.cpp @@ -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 diff --git a/native/cocos/platform/FileUtils.cpp b/native/cocos/platform/FileUtils.cpp index 79e639fb5c..832bc8e803 100644 --- a/native/cocos/platform/FileUtils.cpp +++ b/native/cocos/platform/FileUtils.cpp @@ -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; } } diff --git a/native/cocos/renderer/gfx-metal/MTLUtils.mm b/native/cocos/renderer/gfx-metal/MTLUtils.mm index 37f9793b73..170d8bfbdd 100644 --- a/native/cocos/renderer/gfx-metal/MTLUtils.mm +++ b/native/cocos/renderer/gfx-metal/MTLUtils.mm @@ -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(pipelineState)->getGPUPipelineState();