Skip to content

set diff timeout and fix id_to_slot - #15

Merged
pallavJha merged 11 commits into
masterfrom
upstream-parity
Sep 16, 2026
Merged

pallavJha merged 11 commits into
masterfrom
upstream-parity

Conversation

@pallavJha

@pallavJha pallavJha commented Sep 15, 2026 •

Copy link
Copy Markdown
Collaborator

This PR adds:

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.
@pallavJha
pallavJha requested a review from ajitk September 15, 2026 11:47
@pallavJha pallavJha changed the title set diff timeout, fix id_to_slot and use half_match based on half_match_min_len set diff timeout and fix id_to_slot Sep 15, 2026
Comment thread crates/dmp/oracle/vendor/diff_match_patch_test.js Outdated
@pallavJha
pallavJha merged commit 4653711 into master Sep 16, 2026
4 checks passed
@pallavJha
pallavJha deleted the upstream-parity branch September 16, 2026 06:45
@pallavJha

Copy link
Copy Markdown
Collaborator Author

Published v0.3.1 https://crates.io/crates/diff_match_patch/versions

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants