From 32270c101d0bfb04d4f2791af894d016c233fb1e Mon Sep 17 00:00:00 2001 From: ChunelFeng Date: Sat, 3 Aug 2024 19:08:36 +0800 Subject: [PATCH] [perf] delete useless line. change Uint->UInt. --- src/CBasic/CValType.h | 2 +- src/DomainCtrl/Ann/DAnnNode.cpp | 18 +++++++++--------- src/DomainCtrl/Ann/DAnnNode.h | 2 +- src/GraphCtrl/GraphElement/GElement.cpp | 2 +- .../GraphElement/GGroup/GRegion/GRegion.cpp | 3 --- src/GraphCtrl/GraphMessage/GMessage.h | 8 ++++---- src/GraphCtrl/GraphMessage/GMessageManager.h | 8 ++++---- .../GraphPipeline/_GPerf/GPerfDefine.h | 2 +- .../ThreadPool/Queue/UAtomicRingBufferQueue.h | 12 ++++++------ src/UtilsCtrl/ThreadPool/UThreadPoolDefine.h | 2 +- 10 files changed, 28 insertions(+), 31 deletions(-) diff --git a/src/CBasic/CValType.h b/src/CBasic/CValType.h index 18aad097..5114625b 100644 --- a/src/CBasic/CValType.h +++ b/src/CBasic/CValType.h @@ -15,7 +15,7 @@ using CChar = CGraph::internal::CCHAR; using CCharPtr = CGraph::internal::CCHAR *; -using CUint = CGraph::internal::CUINT; +using CUInt = CGraph::internal::CUINT; using CSize = CGraph::internal::CSIZE; using CVoid = CGraph::internal::CVOID; using CVoidPtr = CGraph::internal::CVOID *; diff --git a/src/DomainCtrl/Ann/DAnnNode.cpp b/src/DomainCtrl/Ann/DAnnNode.cpp index bf1b9533..6312ecd3 100644 --- a/src/DomainCtrl/Ann/DAnnNode.cpp +++ b/src/DomainCtrl/Ann/DAnnNode.cpp @@ -14,14 +14,14 @@ DAnnNode::DAnnNode() { setType(GNodeType::CPU); // 计算密集型算子 /** 初始化函数映射关系 */ - ann_func_arr_[static_cast(DAnnFuncType::ANN_TRAIN)] = &DAnnNode::train; - ann_func_arr_[static_cast(DAnnFuncType::ANN_SEARCH)] = &DAnnNode::search; - ann_func_arr_[static_cast(DAnnFuncType::ANN_INSERT)] = &DAnnNode::insert; - ann_func_arr_[static_cast(DAnnFuncType::ANN_UPDATE)] = &DAnnNode::update; - ann_func_arr_[static_cast(DAnnFuncType::ANN_REMOVE)] = &DAnnNode::remove; - ann_func_arr_[static_cast(DAnnFuncType::ANN_LOAD_MODEL)] = &DAnnNode::loadModel; - ann_func_arr_[static_cast(DAnnFuncType::ANN_SAVE_MODEL)] = &DAnnNode::saveModel; - ann_func_arr_[static_cast(DAnnFuncType::ANN_EDITION)] = &DAnnNode::edition; + ann_func_arr_[static_cast(DAnnFuncType::ANN_TRAIN)] = &DAnnNode::train; + ann_func_arr_[static_cast(DAnnFuncType::ANN_SEARCH)] = &DAnnNode::search; + ann_func_arr_[static_cast(DAnnFuncType::ANN_INSERT)] = &DAnnNode::insert; + ann_func_arr_[static_cast(DAnnFuncType::ANN_UPDATE)] = &DAnnNode::update; + ann_func_arr_[static_cast(DAnnFuncType::ANN_REMOVE)] = &DAnnNode::remove; + ann_func_arr_[static_cast(DAnnFuncType::ANN_LOAD_MODEL)] = &DAnnNode::loadModel; + ann_func_arr_[static_cast(DAnnFuncType::ANN_SAVE_MODEL)] = &DAnnNode::saveModel; + ann_func_arr_[static_cast(DAnnFuncType::ANN_EDITION)] = &DAnnNode::edition; } @@ -39,7 +39,7 @@ CStatus DAnnNode::run() { CGRAPH_RETURN_ERROR_STATUS("error ann function type") } - status = (this->*ann_func_arr_[static_cast(funcType)])(); + status = (this->*ann_func_arr_[static_cast(funcType)])(); CGRAPH_FUNCTION_CHECK_STATUS status = refreshParam(); diff --git a/src/DomainCtrl/Ann/DAnnNode.h b/src/DomainCtrl/Ann/DAnnNode.h index f0f734ad..31905149 100644 --- a/src/DomainCtrl/Ann/DAnnNode.h +++ b/src/DomainCtrl/Ann/DAnnNode.h @@ -91,7 +91,7 @@ class DAnnNode : public DAnnObject, public GNode { private: typedef CStatus (DAnnNode::*DAnnNodeFuncPtr)(); - DAnnNodeFuncPtr ann_func_arr_[static_cast(DAnnFuncType::ANN_MAX_SIZE)]{}; // ann函数映射关系 + DAnnNodeFuncPtr ann_func_arr_[static_cast(DAnnFuncType::ANN_MAX_SIZE)]{}; // ann函数映射关系 }; CGRAPH_NAMESPACE_END diff --git a/src/GraphCtrl/GraphElement/GElement.cpp b/src/GraphCtrl/GraphElement/GElement.cpp index b8d1620e..7b54ae7b 100644 --- a/src/GraphCtrl/GraphElement/GElement.cpp +++ b/src/GraphCtrl/GraphElement/GElement.cpp @@ -169,7 +169,7 @@ CStatus GElement::addDependGElements(const GElementPtrSet& elements) { CStatus GElement::addElementInfo(const GElementPtrSet& dependElements, const std::string& name, CSize loop) { CGRAPH_FUNCTION_BEGIN - CGRAPH_ASSERT_INIT_THROW_ERROR(false) + CGRAPH_ASSERT_INIT(false) // 添加依赖的时候,可能会出现异常情况。故在这里提前添加 && 做判定 status = this->addDependGElements(dependElements); diff --git a/src/GraphCtrl/GraphElement/GGroup/GRegion/GRegion.cpp b/src/GraphCtrl/GraphElement/GGroup/GRegion/GRegion.cpp index b71e3731..45b27dab 100644 --- a/src/GraphCtrl/GraphElement/GGroup/GRegion/GRegion.cpp +++ b/src/GraphCtrl/GraphElement/GGroup/GRegion/GRegion.cpp @@ -6,10 +6,7 @@ @Desc: ***************************/ -#include - #include "GRegion.h" -// #include "GraphCtrl/GraphElement/_GOptimizer/GOptimizerInclude.h" #include "../../_GOptimizer/GOptimizerInclude.h" CGRAPH_NAMESPACE_BEGIN diff --git a/src/GraphCtrl/GraphMessage/GMessage.h b/src/GraphCtrl/GraphMessage/GMessage.h index adc015f8..86422513 100644 --- a/src/GraphCtrl/GraphMessage/GMessage.h +++ b/src/GraphCtrl/GraphMessage/GMessage.h @@ -16,11 +16,11 @@ CGRAPH_NAMESPACE_BEGIN -template::value, int> = 0> class GMessage : public GMessageObject { public: - explicit GMessage(CUint size = capacity) { + explicit GMessage(CUInt size = capacity) { queue_.setCapacity(size); } @@ -86,7 +86,7 @@ class GMessage : public GMessageObject { * 获取容量大小 * @return */ - CUint getCapacity() const { + CUInt getCapacity() const { return queue_.getCapacity(); } @@ -95,7 +95,7 @@ class GMessage : public GMessageObject { }; -template +template using GMessagePtr = GMessage *; CGRAPH_NAMESPACE_END diff --git a/src/GraphCtrl/GraphMessage/GMessageManager.h b/src/GraphCtrl/GraphMessage/GMessageManager.h index 153d7f19..8a6a41e7 100644 --- a/src/GraphCtrl/GraphMessage/GMessageManager.h +++ b/src/GraphCtrl/GraphMessage/GMessageManager.h @@ -33,7 +33,7 @@ class GMessageManager : public GMessageObject, */ template::value, int> = 0> - CStatus createTopic(const std::string& topic, CUint size) { + CStatus createTopic(const std::string& topic, CUInt size) { CGRAPH_FUNCTION_BEGIN auto innerTopic = internal::SEND_RECV_PREFIX + topic; // 中间做一层映射,用来区分是 PubSub的,还是SendRecv的 @@ -45,7 +45,7 @@ class GMessageManager : public GMessageObject, ? CStatus() : CErrStatus("create topic [" + topic + "] duplicate"); } else { // 创建一个 topic信息 - auto message = UAllocator::safeMallocTemplateCObject, CUint>(size); + auto message = UAllocator::safeMallocTemplateCObject, CUInt>(size); send_recv_message_map_.insert(std::pair >(innerTopic, GMessagePtr(message))); } @@ -190,9 +190,9 @@ class GMessageManager : public GMessageObject, */ template::value, int> = 0> - CIndex bindTopic(const std::string& topic, CUint size) { + CIndex bindTopic(const std::string& topic, CUInt size) { auto innerTopic = internal::PUB_SUB_PREFIX + topic; - auto message = UAllocator::safeMallocTemplateCObject, CUint>(size); + auto message = UAllocator::safeMallocTemplateCObject, CUInt>(size); CGRAPH_LOCK_GUARD lock(bind_mutex_); CIndex connId = (++cur_conn_id_); diff --git a/src/GraphCtrl/GraphPipeline/_GPerf/GPerfDefine.h b/src/GraphCtrl/GraphPipeline/_GPerf/GPerfDefine.h index fbc1163d..5b3f3f50 100644 --- a/src/GraphCtrl/GraphPipeline/_GPerf/GPerfDefine.h +++ b/src/GraphCtrl/GraphPipeline/_GPerf/GPerfDefine.h @@ -14,7 +14,7 @@ CGRAPH_NAMESPACE_BEGIN struct GPerfInfo : public CStruct { - CUint loop_ = 0; // 循环数 + CUInt loop_ = 0; // 循环数 CFMSec first_start_ts_ = 0.0; // 开始的时间戳 CFMSec last_finish_ts_ = 0.0; // 最后一次结束的时间(需要考虑多次执行,或者多次被循环执行的情况) CFMSec accu_cost_ts_ = 0.0; // 总体的耗时信息(累计值) diff --git a/src/UtilsCtrl/ThreadPool/Queue/UAtomicRingBufferQueue.h b/src/UtilsCtrl/ThreadPool/Queue/UAtomicRingBufferQueue.h index 7b3ab3b8..fb425d0b 100644 --- a/src/UtilsCtrl/ThreadPool/Queue/UAtomicRingBufferQueue.h +++ b/src/UtilsCtrl/ThreadPool/Queue/UAtomicRingBufferQueue.h @@ -17,7 +17,7 @@ CGRAPH_NAMESPACE_BEGIN -template +template class UAtomicRingBufferQueue : public UQueueObject { public: explicit UAtomicRingBufferQueue() { @@ -37,7 +37,7 @@ class UAtomicRingBufferQueue : public UQueueObject { * @return * @notice 谨慎使用,push信息之后,不推荐使用 */ - UAtomicRingBufferQueue* setCapacity(CUint size) { + UAtomicRingBufferQueue* setCapacity(CUInt size) { capacity_ = size; ring_buffer_queue_.resize(capacity_); return this; @@ -47,7 +47,7 @@ class UAtomicRingBufferQueue : public UQueueObject { * 获取容量信息 * @return */ - CUint getCapacity() const { + CUInt getCapacity() const { return capacity_; } @@ -199,9 +199,9 @@ class UAtomicRingBufferQueue : public UQueueObject { CGRAPH_NO_ALLOWED_COPY(UAtomicRingBufferQueue) private: - CUint head_; // 头结点位置 - CUint tail_; // 尾结点位置 - CUint capacity_; // 环形缓冲的容量大小 + CUInt head_; // 头结点位置 + CUInt tail_; // 尾结点位置 + CUInt capacity_; // 环形缓冲的容量大小 std::condition_variable push_cv_; // 写入的条件变量。为了保持语义完整,也考虑今后多入多出的可能性,不使用 父类中的 cv_了 std::condition_variable pop_cv_; // 读取的条件变量 diff --git a/src/UtilsCtrl/ThreadPool/UThreadPoolDefine.h b/src/UtilsCtrl/ThreadPool/UThreadPoolDefine.h index 288352eb..66da9521 100644 --- a/src/UtilsCtrl/ThreadPool/UThreadPoolDefine.h +++ b/src/UtilsCtrl/ThreadPool/UThreadPoolDefine.h @@ -37,7 +37,7 @@ static const int CGRAPH_THREAD_SCHED_FIFO = 0; static const CInt CGRAPH_THREAD_MIN_PRIORITY = 0; // 线程最低优先级 static const CInt CGRAPH_THREAD_MAX_PRIORITY = 99; // 线程最高优先级 static const CMSec CGRAPH_MAX_BLOCK_TTL = 1999999999; // 最大阻塞时间,单位为ms -static const CUint CGRAPH_DEFAULT_RINGBUFFER_SIZE = 64; // 默认环形队列的大小 +static const CUInt CGRAPH_DEFAULT_RINGBUFFER_SIZE = 64; // 默认环形队列的大小 static const CIndex CGRAPH_MAIN_THREAD_ID = -1; // 启动线程id标识(非上述主线程) static const CIndex CGRAPH_SECONDARY_THREAD_COMMON_ID = -2; // 辅助线程统一id标识 static const CInt CGRAPH_DEFAULT_PRIORITY = 0; // 默认优先级