summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorJean Boussier <jean.boussier@gmail.com>2026-01-19 08:43:57 +0100
committerJean Boussier <jean.boussier@gmail.com>2026-01-20 08:33:42 +0100
commit11d29d32d270d2a98642858fdca25a5272563995 (patch)
treeae21a602858d45e74b7a0d167693e4f8fb4e4865 /lib
parent27bb1623cd048f3cbfc527cc315894803deabba2 (diff)
file.c: strrdirsep search from the back of the string for common encodings
`strrdirsep` quite innficiently search for the last separator from the front of the string. This is surprising but necessary because in Shift-JS, `0x5c` can be the second byte of some multi-byte characters, as such it's not possible to do a pure ASCII search. And it's even more costly because for each character we need to do expensive checks to handle this possibility. However in the overwhelming majority of cases, paths are encoded in UTF-8 or ASCII, so for these common encodings we can use the more logical and efficient algorithm. ``` compare-ruby: ruby 4.1.0dev (2026-01-17T14:40:03Z master 00a3b71eaf) +PRISM [arm64-darwin25] built-ruby: ruby 4.1.0dev (2026-01-19T07:43:57Z file-dirname-lower.. a8d3535e5b) +PRISM [arm64-darwin25] ``` | |compare-ruby|built-ruby| |:------|-----------:|---------:| |long | 3.974M| 23.674M| | | -| 5.96x| |short | 15.281M| 29.034M| | | -| 1.90x|
Diffstat (limited to 'lib')
0 files changed, 0 insertions, 0 deletions