Repository navigation
set diff timeout and fix id_to_slot - #15
Merged
Merged
Conversation
Upstream JS defaults Diff_Timeout = 1.0; the crate defaulted to None, so callers silently got no deadline AND no half-match speedup. The golden corpus stays generated at Diff_Timeout = 0 for determinism, so golden.rs now builds every Dmp through oracle_dmp() (diff_timeout: None — the faithful mapping of the oracle config), and the header documents the split. Callers wanting the old behavior set diff_timeout: None explicitly.
Line ids skip U+D800..U+DFFF on the encode side (slot 55296 becomes scalar 57344), but both decoders indexed their table by RAW id: past 55,295 unique lines diff_chars_tolines and the internal chars_tolines_arena either panicked out of bounds or silently rehydrated the line 2048 slots away. New id_to_slot() inverts the jump; ids below the gap are bit-identical to before. Fire test packs 57,500 unique lines through the arena and round-trips; the ported upstream 66,000-line charsToLines test covers the public path.
All 28 functions from google/diff-match-patch's javascript/tests/diff_match_patch_test.js (vendored beside the oracle for provenance), one #[test] per function in file order, throw cases split into #[should_panic] with the crate's messages. Inputs and expectations copied verbatim; the only marked exceptions are the untypable null-input throws, diff_prettyHtml (no API - commented-out port), the two wall-clock bounds, the Diff_Timeout=0 -> None mapping, and edit_cost=4 set explicitly where upstream relies on the JS default. Porting this suite is what exposed the surrogate-gap decoder bug fixed in the previous commit (the 66,000-line charsToLines round-trip); 31/31 green with it.
id_to_slot and use half_match based on half_match_min_lenid_to_slot
ajitk
approved these changes
Sep 15, 2026
Collaborator
Author
|
Published v0.3.1 https://crates.io/crates/diff_match_patch/versions |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This PR adds:
Diff#newto setupdiff_timeout