-
Notifications
You must be signed in to change notification settings - Fork 113
Properly order the metrics results #807
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -148,7 +148,7 @@ void CppMetricsServiceHandler::getCppMetricsForModule( | |||||
| } | ||||||
|
|
||||||
| void CppMetricsServiceHandler::queryCppAstNodeMetricsForPath( | ||||||
| std::map<core::AstNodeId, std::vector<CppMetricsAstNodeSingle>>& _return, | ||||||
| std::vector<CppMetricsAstNodeEntry>& result_, | ||||||
| const odb::query<model::CppAstNodeMetricsForPathView>& query_) | ||||||
| { | ||||||
| _transaction([&, this](){ | ||||||
|
|
@@ -161,30 +161,40 @@ void CppMetricsServiceHandler::queryCppAstNodeMetricsForPath( | |||||
| metric.type = static_cast<CppAstNodeMetricsType::type>(node.type); | ||||||
| metric.value = node.value; | ||||||
|
|
||||||
| if (_return.count(std::to_string(node.astNodeId))) | ||||||
| // Try to find existing entry with same astNodeId | ||||||
| auto it = std::find_if(result_.begin(), result_.end(), | ||||||
| [&](const CppMetricsAstNodeEntry& entry) { | ||||||
| return std::stoull(entry.astNodeId) == node.astNodeId; | ||||||
| }); | ||||||
|
|
||||||
| if (it != result_.end()) | ||||||
| { | ||||||
| _return[std::to_string(node.astNodeId)].push_back(metric); | ||||||
| // Found existing entry → append metric | ||||||
| it->metrics.push_back(metric); | ||||||
| } | ||||||
|
|
||||||
| else | ||||||
| { | ||||||
| std::vector<CppMetricsAstNodeSingle> metricsList; | ||||||
| metricsList.push_back(metric); | ||||||
| _return.insert(std::make_pair(std::to_string(node.astNodeId), metricsList)); | ||||||
| // No entry for this astNodeId → create new one | ||||||
| CppMetricsAstNodeEntry entry; | ||||||
| entry.astNodeId = std::to_string(node.astNodeId); | ||||||
| entry.metrics.push_back(metric); | ||||||
| result_.push_back(std::move(entry)); | ||||||
| } | ||||||
| } | ||||||
| }); | ||||||
| } | ||||||
|
|
||||||
| void CppMetricsServiceHandler::getCppAstNodeMetricsForPath( | ||||||
| std::map<core::AstNodeId, std::vector<CppMetricsAstNodeSingle>>& _return, | ||||||
| std::vector<CppMetricsAstNodeEntry>& _return, | ||||||
| const std::string& path_) | ||||||
| { | ||||||
| queryCppAstNodeMetricsForPath(_return, | ||||||
| CppNodeMetricsQuery::LocFile::path.like(path_ + '%')); | ||||||
| } | ||||||
|
|
||||||
| void CppMetricsServiceHandler::getPagedCppAstNodeMetricsForPath( | ||||||
| std::map<core::AstNodeId, std::vector<CppMetricsAstNodeSingle>>& _return, | ||||||
| std::vector<CppMetricsAstNodeEntry>& _return, | ||||||
| const std::string& path_, | ||||||
| const std::int32_t pageSize_, | ||||||
| const core::AstNodeId& previousId_) | ||||||
|
|
@@ -197,7 +207,7 @@ void CppMetricsServiceHandler::getPagedCppAstNodeMetricsForPath( | |||||
| } | ||||||
|
|
||||||
| void CppMetricsServiceHandler::queryCppAstNodeMetricsDetailedForPath( | ||||||
| std::map<core::AstNodeId, CppMetricsAstNodeDetailed>& _return, | ||||||
| std::vector<CppMetricsAstNodeDetailedEntry>& result_, | ||||||
| const odb::query<model::CppAstNodeMetricsAndDataForPathView>& query_) | ||||||
| { | ||||||
| _transaction([&, this](){ | ||||||
|
|
@@ -206,12 +216,21 @@ void CppMetricsServiceHandler::queryCppAstNodeMetricsDetailedForPath( | |||||
| for (const auto& node : nodes) | ||||||
| { | ||||||
| auto pair = std::make_pair(static_cast<CppAstNodeMetricsType::type>(node.type), node.value); | ||||||
| if (_return.count(std::to_string(node.astNodeId))) | ||||||
|
|
||||||
| // Try to find existing entry with same astNodeId | ||||||
| auto it = std::find_if(result_.begin(), result_.end(), | ||||||
| [&](const CppMetricsAstNodeDetailedEntry& entry) { | ||||||
| return std::stoull(entry.astNodeId) == node.astNodeId; | ||||||
|
||||||
| return std::stoull(entry.astNodeId) == node.astNodeId; | |
| return entry.astNodeIdNum == node.astNodeId; |
Copilot
AI
Aug 26, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Converting string to unsigned long long for every comparison creates a performance bottleneck. Consider storing the numeric ID alongside the string ID in the entry struct to avoid repeated conversions.
| return std::stoull(entry.fileId) == file.fileId; | |
| return entry.fileIdNumeric == file.fileId; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Converting string to unsigned long long for every comparison creates a performance bottleneck. Consider storing the numeric ID alongside the string ID in the entry struct to avoid repeated conversions.