perf(content): replace manifest linear scans with binary search
record() and upsert() use partition_point on the path-sorted file list and reconcile_inventory appends records in order instead of upserting each one, dropping full rescans from O(n^2) to O(n log n).
This commit is contained in:
1 parent
7f07c7636c
commit
cc3b783ab1
2 files changed
+33
-11
No files matched your search
@@ -1,3 +1,6 @@
|
||||
// SPDX-FileCopyrightText: 2026 Constantin Bauer
|
||||
// SPDX-License-Identifier: GPL-3.0-only
|
||||
|
||||
use std::collections::{HashMap, HashSet, VecDeque};
|
||||
use std::path::{Path, PathBuf};
|
||||
use std::sync::{Arc, LazyLock, Mutex};
|
||||
@@ -428,7 +431,10 @@ fn reconcile_inventory(
|
||||
fingerprint: record.fingerprint.clone(),
|
||||
});
|
||||
}
|
||||
manifest.upsert(record);
|
||||
// content_files() yields paths in sorted order and stripping the
|
||||
// common prefix preserves that order, so appending keeps manifest
|
||||
// files sorted without an O(log n) lookup per record.
|
||||
manifest.files.push(record);
|
||||
task.set_progress(index as u64 + 1, file_count);
|
||||
}
|
||||
Ok(Inventory { manifest, queries })
|
||||
|
||||
Reference in new issue
Block a user