You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
fix: recover two per-op editing slowdowns regressed since 1.11 (#1021)
* fix: recover two per-op editing slowdowns regressed since 1.11
Both are constant-factor regressions on the per-op (auto-commit) editing
path introduced by the lazy-snapshot work in #985, found while bisecting
current HEAD against the 1.11.1 release.
1. map/list/movable-list insert: ensure_no_regular_container_value
heap-allocated a Vec on every insert, even for scalar values (the
common case). Add a scalar fast-path that skips the allocation and
traversal. `map create 10^4 key`: ~19.4ms -> ~10.7ms.
2. text insert/delete: the per-op bounds-check len()/len_unicode()/
len_utf16() took two DocState locks (decoded-check, then query).
Consolidate into one DocState::get_text_len taking a single lock +
container-store lookup, preserving the lazy-snapshot memory behavior
(a still-lazy container reads cached length metadata without
materializing the richtext state). `bench_text B4 apply`: ~389ms -> ~352ms.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
* chore: sync Cargo.lock with loro-wasm 1.13.4 version bump
Lockfile update to match the crates/loro-wasm Cargo.toml version bump that
landed via the main merge (chore: version packages).
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
* fix: read cached byte length for PosType::Bytes text len
Addresses a review finding on the per-op text length consolidation: the
PosType::Bytes branch of DocState::get_text_len built the full plain string
via get_value_by_idx().as_string().len(), so insert_utf8/delete_utf8 bounds
checks on an already-decoded text became O(text length) per op (the old code
read cached byte-length metadata in the decoded case).
Add a text_utf8_len store helper mirroring text_unicode_len/text_utf16_len:
- decoded state reads the O(1) cached byte length
(RichtextState::len_utf8 = root_cache().bytes)
- a still-lazy container reads the byte length from the already-materialized
text value string (O(1) str::len), preserving the no-force-decode behavior
Also route the public TextHandler::len_utf8 through the same single-lock
helper; it had the same has_decoded_state double-lock + string-construction
pattern.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
---------
Co-authored-by: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
0 commit comments