[Lldb-commits] [lldb] 174899f - [lldb] Refactor helper by using iterators and in-place edits (NFC) (#116876)
via lldb-commits
lldb-commits at lists.llvm.org
Tue Nov 19 13:02:50 PST 2024
Author: Adrian Prantl
Date: 2024-11-19T13:02:47-08:00
New Revision: 174899f738b31216750ac59562475966b0b0be42
URL: https://github.com/llvm/llvm-project/commit/174899f738b31216750ac59562475966b0b0be42
DIFF: https://github.com/llvm/llvm-project/commit/174899f738b31216750ac59562475966b0b0be42.diff
LOG: [lldb] Refactor helper by using iterators and in-place edits (NFC) (#116876)
Based on post-commit review feedback by Felipe Piovezan!
Added:
Modified:
lldb/source/Utility/DiagnosticsRendering.cpp
Removed:
################################################################################
diff --git a/lldb/source/Utility/DiagnosticsRendering.cpp b/lldb/source/Utility/DiagnosticsRendering.cpp
index a20d82ad4eb678..f5aa27baadfef8 100644
--- a/lldb/source/Utility/DiagnosticsRendering.cpp
+++ b/lldb/source/Utility/DiagnosticsRendering.cpp
@@ -132,23 +132,16 @@ void RenderDiagnosticDetails(Stream &stream,
stream << '\n';
// Reverse the order within groups of diagnostics that are on the same column.
- auto group = [](const std::vector<DiagnosticDetail> &details) {
- uint16_t column = 0;
- std::vector<DiagnosticDetail> result, group;
- for (auto &d : details) {
- if (d.source_location->column == column) {
- group.push_back(d);
- continue;
- }
- result.insert(result.end(), group.rbegin(), group.rend());
- group.clear();
- column = d.source_location->column;
- group.push_back(d);
+ auto group = [](std::vector<DiagnosticDetail> &details) {
+ for (auto it = details.begin(), end = details.end(); it != end;) {
+ auto eq_end = std::find_if(it, end, [&](const DiagnosticDetail &d) {
+ return d.source_location->column != it->source_location->column;
+ });
+ std::reverse(it, eq_end);
+ it = eq_end;
}
- result.insert(result.end(), group.rbegin(), group.rend());
- return result;
};
- remaining_details = group(remaining_details);
+ group(remaining_details);
// Work through each detail in reverse order using the vector/stack.
bool did_print = false;
More information about the lldb-commits
mailing list