nsTStringRepr<T>::Equals should probably compare bytes also from the end of the data
Categories
(Core :: String, enhancement)
Tracking
()
People
(Reporter: smaug, Unassigned)
Details
https://searchfox.org/mozilla-central/rev/b0844a16d60042c8e1e8f50465a89c1696d283fb/xpcom/string/nsCharTraits.h#143 is used for Equals.
It goes through data from the beginning, but appending to a string is a common thing on the web. That shows up in https://bugzilla.mozilla.org/show_bug.cgi?id=1533032#c18
Comment 1•3 years ago
|
||
The nsCharTraits stuff returns not just equality, but break unequality to lexicographically less-than or greater-than. However, the callers only care about equal or unequal. So that's not a reason to compare forward.
These days caches should work with consistently backward-progressing reads.
memcmp also uselessly returns less-than/greater-than and compares forward.
I wonder if it's worthwhile to try to manually unroll by 8 for char16_t or by 16 for unsigned char to get basic autovectorization.
Comment 2•3 years ago
|
||
We should probably loop backwards and unroll in a way that autovectorizes. x86_64: https://godbolt.org/z/1T54Wdc9b ; not quite as nice on aarch64: https://godbolt.org/z/sT158hn9W
Description
•