From 88a25f6ea0414b3632b67b47eb34242d8a45dfb3 Mon Sep 17 00:00:00 2001 From: ChestnutYueyue <952134128@qq.com> Date: Mon, 23 Feb 2026 02:20:24 +0800 Subject: [PATCH] =?UTF-8?q?refactor(core):=20=E4=BC=98=E5=8C=96=E6=A8=A1?= =?UTF-8?q?=E5=9D=97=E4=BE=9D=E8=B5=96=E6=A3=80=E6=9F=A5=E4=B8=AD=E7=9A=84?= =?UTF-8?q?=E7=B1=BB=E5=9E=8B=E7=B4=A2=E5=BC=95=E8=AE=BF=E9=97=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 将直接访问 modules_[j].module 改为先获取引用再访问,减少重复解引用操作,提高代码可读性 --- Extra2D/src/core/registry.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/Extra2D/src/core/registry.cpp b/Extra2D/src/core/registry.cpp index 9b5529b..964a864 100644 --- a/Extra2D/src/core/registry.cpp +++ b/Extra2D/src/core/registry.cpp @@ -122,8 +122,8 @@ std::vector Registry::sort() { for (auto &depType : deps) { // 查找依赖模块的索引 for (size_t j = 0; j < moduleCount_; ++j) { - if (modules_[j].valid && - std::type_index(typeid(*modules_[j].module)) == depType) { + auto &mod = *modules_[j].module; + if (modules_[j].valid && std::type_index(typeid(mod)) == depType) { adj[j].push_back(i); inDegree[i]++; break; @@ -173,8 +173,8 @@ std::vector> Registry::group() { auto deps = modules_[i].module->deps(); for (auto &depType : deps) { for (size_t j = 0; j < moduleCount_; ++j) { - if (modules_[j].valid && - std::type_index(typeid(*modules_[j].module)) == depType) { + auto &mod = *modules_[j].module; + if (modules_[j].valid && std::type_index(typeid(mod)) == depType) { adj[j].push_back(i); inDegree[i]++; break;