feat(installer): implement Phase 3 — the patch tier #6

Merged
whitlocktech merged 3 commits from feat/phase3-patch-tier into edge 2026-08-05 01:08:07 +00:00
Showing only changes of commit 02c5ad9839 - Show all commits

View File

@@ -259,7 +259,7 @@ pub fn resolve(file: &FilePatch, content: &[u8]) -> Resolution {
}
// Highest offset first, so applying one edit never invalidates the next one's range.
edits.sort_by(|a, b| b.start.cmp(&a.start));
edits.sort_by_key(|e| std::cmp::Reverse(e.start));
Resolution::Applicable {
rung: if stock {
Rung::StockHash
@@ -369,7 +369,7 @@ pub fn apply(content: &[u8], edits: &[Edit]) -> Vec<u8> {
// The edits arrive highest-offset-first from `resolve`, so each splice leaves every remaining
// range valid. Re-sorting here rather than trusting the caller keeps that a local property.
let mut ordered: Vec<&Edit> = edits.iter().collect();
ordered.sort_by(|a, b| b.start.cmp(&a.start));
ordered.sort_by_key(|e| std::cmp::Reverse(e.start));
for edit in ordered {
out.splice(edit.start..edit.end, edit.replacement.iter().copied());
}