Skip to content

Pull input text into a separate type with cached codepoint count#47

Merged
sayanarijit merged 2 commits intosayanarijit:mainfrom
cammeresi:20260416-opt
Apr 18, 2026
Merged

Pull input text into a separate type with cached codepoint count#47
sayanarijit merged 2 commits intosayanarijit:mainfrom
cammeresi:20260416-opt

Conversation

@cammeresi
Copy link
Copy Markdown
Contributor

Several editing or movement operations iterated the entire input string in order to count characters. It would be better to cache the count but in a way that is automatic and not subject to careful maintenance.

We pull the text into a Value type, which only allows modifying the contained string via a guard object (ValueMut), which in turn derefs into the contained string. When the guard is dropped after a mutable deref, the cached character count is updated. Several operations are then optimized.

Several editing or movement operations iterated the entire input string
in order to count characters.  It would be better to cache the count but
in a way that is automatic and not subject to careful maintenance.

We pull the text into a `Value` type, which only allows modifying the
contained string via a guard object (`ValueMut`), which in turn derefs
into the contained string.  When the guard is dropped after a mutable
deref, the cached character count is updated.  Several operations are
then optimized.
@sayanarijit
Copy link
Copy Markdown
Owner

Thank you for the pr 👍 . Will review soon.

@sayanarijit
Copy link
Copy Markdown
Owner

Nice...

@sayanarijit sayanarijit merged commit 4d12c31 into sayanarijit:main Apr 18, 2026
1 check passed
@cammeresi cammeresi deleted the 20260416-opt branch April 18, 2026 15:55
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