summaryrefslogtreecommitdiff
path: root/benchmark/file_dirname.yml
AgeCommit message (Collapse)Author
2026-01-20file.c: dirname_n also use strrdirsep when n > 1Jean Boussier
It's both simpler and faster. | |compare-ruby|built-ruby| |:------|-----------:|---------:| |long | 3.960M| 24.072M| | | -| 6.08x| |short | 15.417M| 29.841M| | | -| 1.94x| |n_4 | 3.858M| 18.415M| | | -| 4.77x|
2026-01-20file.c: Optimize `rb_file_dirname_n` fixed costsJean Boussier
- `str_null_check` was performed twice, once by `FilePathStringValue` and a second time by `StringValueCStr`. - `StringValueCStr` was checking for the terminator presence, but we don't care about that. - `FilePathStringValue` calls `rb_str_new_frozen` to ensure `fname` isn't mutated, but that's costly for such a check. Instead we can do it in debug mode only. - `rb_enc_get` is slow because it accepts arbitrary objects, even immediates, so it has to do numerous type checks. Add a much faster `rb_str_enc_get` when we know we're dealing with a string. - `rb_enc_copy` is slow for the same reasons, since we already have the encoding, we can use `rb_enc_str_new` instead.