29 lines
892 B
Diff
29 lines
892 B
Diff
# UNDF: UNDF-2026-000000870
|
|
--- a/src/Notes.cc
|
|
+++ b/src/Notes.cc
|
|
@@ -27,6 +27,7 @@
|
|
#include <algorithm>
|
|
#include <ostream>
|
|
#include <string>
|
|
+#include <set>
|
|
|
|
Note::Value::~Value()
|
|
{
|
|
@@ -388,9 +389,16 @@ NotePairs::append(const NotePairs *src)
|
|
void
|
|
NotePairs::appendNewOnly(const NotePairs *src)
|
|
{
|
|
+ // Build a set of existing (name, value) pairs for O(1) lookup
|
|
+ // instead of linear hasPair() scan per source entry.
|
|
+ std::set<std::pair<SBuf, SBuf>> existing;
|
|
+ for (const auto &e: entries)
|
|
+ existing.emplace(e->name(), e->value());
|
|
+
|
|
for (const auto &e: src->entries) {
|
|
- if (!hasPair(e->name(), e->value()))
|
|
+ if (existing.find(std::make_pair(e->name(), e->value())) == existing.end()) {
|
|
entries.push_back(new NotePairs::Entry(e->name(), e->value()));
|
|
+ existing.emplace(e->name(), e->value());
|
|
+ }
|
|
}
|
|
}
|