Skip to content

Commit

Permalink
[perf] optimize group function, no need to override addElement()
Browse files Browse the repository at this point in the history
  • Loading branch information
ChunelFeng committed May 9, 2024
1 parent e4d98fb commit 2c42a2b
Show file tree
Hide file tree
Showing 11 changed files with 16 additions and 44 deletions.
3 changes: 1 addition & 2 deletions src/GraphCtrl/GraphElement/GElement.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -175,8 +175,7 @@ CStatus GElement::addDependGElements(const GElementPtrSet& elements) {


CStatus GElement::addElementInfo(const GElementPtrSet& dependElements,
const std::string& name,
CSize loop) {
const std::string& name, CSize loop) {
CGRAPH_FUNCTION_BEGIN
CGRAPH_ASSERT_INIT_THROW_ERROR(false)

Expand Down
11 changes: 4 additions & 7 deletions src/GraphCtrl/GraphElement/GElement.h
Original file line number Diff line number Diff line change
Expand Up @@ -231,13 +231,13 @@ class GElement : public GElementObject,
* run方法执行之前的执行函数
* @return
*/
virtual CVoid beforeRun();
CVoid beforeRun();

/**
* run方法执行之后的执行函数
* @return
*/
virtual CVoid afterRun();
CVoid afterRun();

/**
* 判定node是否可以和前面节点一起执行
Expand Down Expand Up @@ -280,8 +280,7 @@ class GElement : public GElementObject,
* @return
*/
virtual CStatus addElementInfo(const std::set<GElement *>& dependElements,
const std::string& name,
CSize loop);
const std::string& name, CSize loop);

/**
* 设置manager信息
Expand Down Expand Up @@ -321,9 +320,7 @@ class GElement : public GElementObject,
* @param label
* @return
*/
CVoid dumpEdge(std::ostream& oss,
GElement* src,
GElement* dst,
CVoid dumpEdge(std::ostream& oss, GElement* src, GElement* dst,
const std::string& label = CGRAPH_EMPTY);

/**
Expand Down
10 changes: 0 additions & 10 deletions src/GraphCtrl/GraphElement/GGroup/GCluster/GCluster.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,16 +27,6 @@ CStatus GCluster::run() {
}


CStatus GCluster::addElement(GElementPtr element) {
CGRAPH_FUNCTION_BEGIN
CGRAPH_ASSERT_NOT_NULL(element)

this->group_elements_arr_.emplace_back(element);

CGRAPH_FUNCTION_END
}


CVoid GCluster::dump(std::ostream& oss) {
dumpElement(oss);
dumpGroupLabelBegin(oss);
Expand Down
2 changes: 0 additions & 2 deletions src/GraphCtrl/GraphElement/GGroup/GCluster/GCluster.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,6 @@ class GCluster : public GGroup {
private:
CStatus run() final;

CStatus addElement(GElementPtr element) final;

CVoid dump(std::ostream& oss) final;

CBool isSeparate(GElementCPtr a, GElementCPtr b) const final;
Expand Down
9 changes: 0 additions & 9 deletions src/GraphCtrl/GraphElement/GGroup/GCondition/GCondition.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,15 +16,6 @@ GCondition::GCondition() {
}


CStatus GCondition::addElement(GElementPtr element) {
CGRAPH_FUNCTION_BEGIN
CGRAPH_ASSERT_NOT_NULL(element)

this->group_elements_arr_.emplace_back(element);
CGRAPH_FUNCTION_END
}


CStatus GCondition::run() {
CGRAPH_FUNCTION_BEGIN

Expand Down
2 changes: 0 additions & 2 deletions src/GraphCtrl/GraphElement/GGroup/GCondition/GCondition.h
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,6 @@ class GCondition : public GGroup {

CStatus run() override;

CStatus addElement(GElementPtr element) final;

CBool isSeparate(GElementCPtr a, GElementCPtr b) const override;

friend class GPipeline;
Expand Down
9 changes: 9 additions & 0 deletions src/GraphCtrl/GraphElement/GGroup/GGroup.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,15 @@ CStatus GGroup::destroy() {
}


CStatus GGroup::addElement(GElementPtr element) {
CGRAPH_FUNCTION_BEGIN
CGRAPH_ASSERT_NOT_NULL(element)

this->group_elements_arr_.emplace_back(element);
CGRAPH_FUNCTION_END
}


CVoid GGroup::dumpGroupLabelBegin(std::ostream& oss) {
oss << "subgraph ";
oss << "cluster_p" << this; // cluster_ 是 graphviz的关键字,和CGraph中GCluster逻辑无关
Expand Down
2 changes: 1 addition & 1 deletion src/GraphCtrl/GraphElement/GGroup/GGroup.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ class GGroup : public GElement {
* @param element
* @return
*/
virtual CStatus addElement(GElementPtr element) = 0;
virtual CStatus addElement(GElementPtr element);

CBool isSerializable() const override;

Expand Down
8 changes: 0 additions & 8 deletions src/GraphCtrl/GraphElement/GGroup/GMutable/GMutable.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,14 +22,6 @@ GMutable::~GMutable() {
}


CStatus GMutable::addElement(GElementPtr element) {
CGRAPH_FUNCTION_BEGIN
CGRAPH_ASSERT_NOT_NULL(element)
this->group_elements_arr_.emplace_back(element);
CGRAPH_FUNCTION_END
}


CStatus GMutable::init() {
CGRAPH_FUNCTION_BEGIN
CGRAPH_ASSERT_NOT_NULL(manager_)
Expand Down
2 changes: 0 additions & 2 deletions src/GraphCtrl/GraphElement/GGroup/GMutable/GMutable.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,6 @@ class GMutable : public GGroup {
~GMutable() override;

private:
CStatus addElement(GElementPtr element) final;

CStatus init() final;

CStatus run() final;
Expand Down
2 changes: 1 addition & 1 deletion src/GraphCtrl/GraphElement/GGroup/GSome/GSome.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ class GSome : public GGroup {
protected:
explicit GSome();

CStatus addElement(GElementPtr element) override;
CStatus addElement(GElementPtr element) final;

CStatus run() final;

Expand Down

0 comments on commit 2c42a2b

Please sign in to comment.