Skip to content

Commit

Permalink
fix(core): fix performance for dom node
Browse files Browse the repository at this point in the history
  • Loading branch information
etkmao authored and hippy-actions[bot] committed Sep 4, 2023
1 parent 208ba93 commit 7da2c69
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
6 changes: 3 additions & 3 deletions dom/src/dom/dom_node.cc
Original file line number Diff line number Diff line change
Expand Up @@ -103,13 +103,13 @@ std::shared_ptr<DomNode> DomNode::GetChildAt(size_t index) {
}

int32_t DomNode::AddChildByRefInfo(const std::shared_ptr<DomInfo>& dom_info) {
std::shared_ptr<RefInfo> ref_info = dom_info->ref_info;
std::shared_ptr<RefInfo>& ref_info = dom_info->ref_info;
if (ref_info) {
if (children_.size() == 0) {
children_.push_back(dom_info->dom_node);
} else {
for (uint32_t i = 0; i < children_.size(); ++i) {
auto child = children_[i];
auto& child = children_[i];
if (ref_info->ref_id == child->GetId()) {
if (ref_info->relative_to_ref == RelativeType::kFront) {
children_.insert(
Expand Down Expand Up @@ -145,7 +145,7 @@ int32_t DomNode::AddChildByRefInfo(const std::shared_ptr<DomInfo>& dom_info) {
int32_t DomNode::GetChildIndex(uint32_t id) {
int32_t index = -1;
for (uint32_t i = 0; i < children_.size(); ++i) {
auto child = children_[i];
auto& child = children_[i];
if (child && child->GetId() == id) {
index = static_cast<int32_t>(i);
break;
Expand Down
2 changes: 1 addition & 1 deletion dom/src/dom/root_node.cc
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ void RootNode::CreateDomNodes(std::vector<std::shared_ptr<DomInfo>>&& nodes) {
}
std::vector<std::shared_ptr<DomNode>> nodes_to_create;
for (const auto& node_info : nodes) {
auto node = node_info->dom_node;
auto& node = node_info->dom_node;
std::shared_ptr<DomNode> parent_node = GetNode(node->GetPid());
if (parent_node == nullptr) {
continue;
Expand Down

0 comments on commit 7da2c69

Please sign in to comment.