Skip to content

Speed up length of valid UTF-8 text strings.#394

Closed
01mf02 wants to merge 1 commit intomainfrom
length-str
Closed

Speed up length of valid UTF-8 text strings.#394
01mf02 wants to merge 1 commit intomainfrom
length-str

Conversation

@01mf02
Copy link
Copy Markdown
Owner

@01mf02 01mf02 commented Feb 10, 2026

This increases performance of length by up to 8x and roughly restores the performance of jq 2.7 (which does not have to account for non-UTF-8 strings). See also BurntSushi/bstr#221.

At the same time, this also omits a cast to isize, which could lead to wrong results for length when loading very large data, e.g. a byte string that contains more than isize bytes.

@01mf02
Copy link
Copy Markdown
Owner Author

01mf02 commented Mar 20, 2026

I've opened a PR BurntSushi/bstr#223 that should improve the situation without resorting to str::from_utf8.

Still, the isize cast should be eliminated.

@01mf02
Copy link
Copy Markdown
Owner Author

01mf02 commented Mar 26, 2026

Closed in favour of #417.

@01mf02 01mf02 closed this Mar 26, 2026
@01mf02 01mf02 deleted the length-str branch March 26, 2026 11:09
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.

1 participant