summaryrefslogtreecommitdiff
path: root/include/ruby/internal/encoding/string.h
diff options
context:
space:
mode:
authorJean Boussier <jean.boussier@gmail.com>2026-01-18 13:49:59 +0100
committerJean Boussier <jean.boussier@gmail.com>2026-01-18 16:31:31 +0100
commit7e0e9984d0250afbd67a17b8b2d6846f1595ddce (patch)
tree7cbd156fa2ccc4611fc82399c378e93da039f6ce /include/ruby/internal/encoding/string.h
parent6cd4549060a608d8a7e5ee0dde2c4b69b08d7f6e (diff)
rb_file_join_fastpath: optimize searching for separators
`chompdirsep` searches from the start of the string each time, which perhaps is necessary for certain encodings (not even sure?) but for the common encodings it's very wasteful. Instead we can start from the back of the string and only compare one or two characters in most cases. Also replace `StringValueCStr` for the simpler `rb_str_null_check` as we only care about whether the string contains `NULL` bytes, we don't care whether it is NULL terminated or not. We also only check the final string for NULLs. ``` compare-ruby: ruby 4.1.0dev (2026-01-17T14:40:03Z master 00a3b71eaf) +PRISM [arm64-darwin25] built-ruby: ruby 4.1.0dev (2026-01-18T12:55:15Z spedup-file-join 5948e92e03) +PRISM [arm64-darwin25] warming up.... | |compare-ruby|built-ruby| |:-------------|-----------:|---------:| |two_strings | 2.477M| 19.317M| | | -| 7.80x| |many_strings | 547.577k| 10.298M| | | -| 18.81x| |array | 515.280k| 523.291k| | | -| 1.02x| |mixed | 621.840k| 635.422k| | | -| 1.02x| ```
Diffstat (limited to 'include/ruby/internal/encoding/string.h')
0 files changed, 0 insertions, 0 deletions