diff --git a/src/GraphCtrl/GraphAspect/GAspectManager.cpp b/src/GraphCtrl/GraphAspect/GAspectManager.cpp index 527a6f80..d118c34b 100644 --- a/src/GraphCtrl/GraphAspect/GAspectManager.cpp +++ b/src/GraphCtrl/GraphAspect/GAspectManager.cpp @@ -21,7 +21,7 @@ GAspectManager::~GAspectManager() { CStatus GAspectManager::reflect(const internal::GAspectType &type, - const CStatus &curStatus) { + const CStatus &curStatus) const { CGRAPH_FUNCTION_BEGIN for (GAspectPtr aspect : aspect_arr_) { diff --git a/src/GraphCtrl/GraphAspect/GAspectManager.h b/src/GraphCtrl/GraphAspect/GAspectManager.h index b4a966ea..8322b9d6 100644 --- a/src/GraphCtrl/GraphAspect/GAspectManager.h +++ b/src/GraphCtrl/GraphAspect/GAspectManager.h @@ -29,7 +29,7 @@ class GAspectManager : public GAspectObject, * @return */ CStatus reflect(const internal::GAspectType& type, - const CStatus& curStatus = CStatus()); + const CStatus& curStatus = CStatus()) const; CStatus add(GAspectPtr aspect) final; diff --git a/src/GraphCtrl/GraphElement/GElement.cpp b/src/GraphCtrl/GraphElement/GElement.cpp index b29d92ca..d264446e 100644 --- a/src/GraphCtrl/GraphElement/GElement.cpp +++ b/src/GraphCtrl/GraphElement/GElement.cpp @@ -205,7 +205,7 @@ CStatus GElement::addManagers(GParamManagerPtr paramManager, } -CStatus GElement::doAspect(const internal::GAspectType& aspectType, const CStatus& curStatus) { +CStatus GElement::doAspect(const internal::GAspectType& aspectType, const CStatus& curStatus) const { CGRAPH_FUNCTION_BEGIN // 如果切面管理类为空,或者未添加切面,直接返回 diff --git a/src/GraphCtrl/GraphElement/GElement.h b/src/GraphCtrl/GraphElement/GElement.h index be8ef3c9..5e49605c 100644 --- a/src/GraphCtrl/GraphElement/GElement.h +++ b/src/GraphCtrl/GraphElement/GElement.h @@ -300,7 +300,7 @@ class GElement : public GElementObject, * @return */ CStatus doAspect(const internal::GAspectType& aspectType, - const CStatus& curStatus = CStatus()); + const CStatus& curStatus = CStatus()) const; /** * 设置element信息 diff --git a/src/GraphCtrl/GraphElement/_GEngine/GDynamicEngine/GDynamicEngine.cpp b/src/GraphCtrl/GraphElement/_GEngine/GDynamicEngine/GDynamicEngine.cpp index 74a6d2f2..77759045 100644 --- a/src/GraphCtrl/GraphElement/_GEngine/GDynamicEngine/GDynamicEngine.cpp +++ b/src/GraphCtrl/GraphElement/_GEngine/GDynamicEngine/GDynamicEngine.cpp @@ -102,16 +102,16 @@ CVoid GDynamicEngine::analysisDagType() { CVoid GDynamicEngine::analysisParallelMatrix() { parallel_element_matrix_.clear(); const auto& config = thread_pool_ ? thread_pool_->getConfig() : UThreadPoolConfig(); - CSize thdSize = config.default_thread_size_ + config.secondary_thread_size_; + const CSize& thdSize = config.default_thread_size_ + config.secondary_thread_size_; CGRAPH_THROW_EXCEPTION_BY_CONDITION(thdSize <= 0, "default thread size cannot smaller than 1"); - CSize taskNumPerThd = total_end_size_ / thdSize + (CSize)(0 != total_end_size_ % thdSize); + const CSize& taskNumPerThd = total_end_size_ / thdSize + static_cast(0 != total_end_size_ % thdSize); CGRAPH_THROW_EXCEPTION_BY_CONDITION(taskNumPerThd == 0, "task number per thread is 0"); CSize curIndex = 0; while (curIndex < total_end_size_) { - CSize curEnd = curIndex + taskNumPerThd < total_end_size_ ? curIndex + taskNumPerThd : total_end_size_ ; + const CSize curEnd = curIndex + taskNumPerThd < total_end_size_ ? curIndex + taskNumPerThd : total_end_size_ ; GElementPtrArr curArr(total_element_arr_.data() + curIndex, total_element_arr_.data() + curEnd); CGRAPH_THROW_EXCEPTION_BY_CONDITION(curArr.empty(), "current elements array cannot be empty"); @@ -233,7 +233,8 @@ CVoid GDynamicEngine::parallelRunAll() { #else CVoid GDynamicEngine::parallelRunAll() { parallel_run_num_ = 0; - for (CIndex i = 0; i < (CIndex)parallel_element_matrix_.size(); i++) { + const CIndex& totalSize = static_cast(parallel_element_matrix_.size()); + for (CIndex i = 0; i < totalSize; i++) { auto& curArr = parallel_element_matrix_[i]; if (curArr.size() > 1) { for (const auto& element : curArr) { @@ -249,7 +250,7 @@ CVoid GDynamicEngine::parallelRunAll() { } } - if (parallel_element_matrix_.size() < (CSize)(thread_pool_->getConfig().default_thread_size_)) { + if (parallel_element_matrix_.size() < static_cast(thread_pool_->getConfig().default_thread_size_)) { // 确保所有的 pt 都可以被唤醒,从而快速执行 thread_pool_->wakeupAllThread(); } @@ -269,7 +270,7 @@ CVoid GDynamicEngine::parallelRunOne(GElementPtr element) { return; } - auto status = element->fatProcessor(CFunctionType::RUN); + const auto& status = element->fatProcessor(CFunctionType::RUN); if (unlikely(status.isErr())) { { CGRAPH_LOCK_GUARD lk(status_lock_); @@ -277,7 +278,7 @@ CVoid GDynamicEngine::parallelRunOne(GElementPtr element) { } } - auto finishedSize = parallel_run_num_.fetch_add(1, std::memory_order_release) + 1; + const auto& finishedSize = parallel_run_num_.fetch_add(1, std::memory_order_release) + 1; if (finishedSize >= total_end_size_ || cur_status_.isErr()) { CGRAPH_UNIQUE_LOCK lock(locker_.mtx_); locker_.cv_.notify_one(); diff --git a/src/GraphCtrl/GraphElement/_GEngine/GStaticEngine/GStaticEngine.cpp b/src/GraphCtrl/GraphElement/_GEngine/GStaticEngine/GStaticEngine.cpp index a38fe49f..661299ab 100644 --- a/src/GraphCtrl/GraphElement/_GEngine/GStaticEngine/GStaticEngine.cpp +++ b/src/GraphCtrl/GraphElement/_GEngine/GStaticEngine/GStaticEngine.cpp @@ -29,7 +29,7 @@ CStatus GStaticEngine::setup(const GSortedGElementPtrSet& elements) { element_mat_.emplace_back(curArr); GElementPtrArr runnableArr = curArr; curArr.clear(); - for (auto element : runnableArr) { + for (const auto element : runnableArr) { for (auto cur : element->run_before_) { if (0 == (--cur->left_depend_)) { curArr.push_back(cur);