diff options
| author | Jean Boussier <jean.boussier@gmail.com> | 2026-01-19 07:32:09 +0100 |
|---|---|---|
| committer | Jean Boussier <jean.boussier@gmail.com> | 2026-01-20 08:33:42 +0100 |
| commit | 27bb1623cd048f3cbfc527cc315894803deabba2 (patch) | |
| tree | a7bcabe824382632378a07ad099ee1fcae1aa0cc /lib | |
| parent | 826dbcfb2be33ffbfbc99554244881e014513d20 (diff) | |
file.c: Optimize `rb_file_dirname_n` fixed costs
- `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.
Diffstat (limited to 'lib')
0 files changed, 0 insertions, 0 deletions
