victory-loader: avoid the image copy with prepare_owned (PREPARE-OWNED-BUFFER) #3727
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/3727"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Imported from Marvisak/VIctory. Originally posted by cloph-dsp on 2026-11-28T12:06:44Z.
Depends on: #1633
What
prepare()copied the whole image (original.to_vec()) before patching it. Callers that already own the bytes —map_dllreads the file into aVec— paid for a second executable-size allocation. Addprepare_owned(Vec<u8>)which takes the buffer by value, hashes the original bytes once, and patches in place.prepare(&[u8])stays as a thin wrapper so borrowed callers are unaffected.Change
crates/victory-loader/src/prepare.rs: addprepare_owned, keepprepareas a wrapper, synthetic test comparing borrowed vs owned preparation (bytes, info, hash, file name).crates/victory-loader/src/lib.rs: re-exportprepare_owned.crates/victory-loader/src/windows.rs:map_dllpasses its already-ownedVecdirectly.Validation
Windows, Rust 1.100.0/MSVC, per-worktree
CARGO_TARGET_DIR,CARGO_BUILD_JOBS=2,--locked:cargo test --locked -p victory-loader --lib -- prepare::tests::owned_buffer_matches_borrowed_preparation --exact --test-threads=1 --quiet→ 1 passed, 0 failed, 35 filtered, exit 0.cargo test --locked -p victory-loader --lib -- prepare::tests --test-threads=1 --quiet→ 5 passed, 0 failed, 31 filtered, exit 0.git grep -Ffor the new test name on base63bcca43c6a00a758510398fa43096ce7e4f7df0: no match (test is new);git diff --checkclean (3 files, +25/-6).GPU/driver: N/A (CPU-only byte manipulation; the Windows load path only changes which owned buffer is handed in). The tests use the local test binary as input — no game data, assets, extracted shaders, DRM or decrypt involved.
AI-assisted (Hy4 flash).
View command line instructions
Checkout
From your project repository, check out a new branch and test the changes.Merge
Merge the changes and update on Forgejo.Warning: The "Autodetect manual merge" setting is not enabled for this repository, you will have to mark this pull request as manually merged afterwards.