diff options
| author | Jean Boussier <jean.boussier@gmail.com> | 2026-01-20 08:56:17 +0100 |
|---|---|---|
| committer | Jean Boussier <jean.boussier@gmail.com> | 2026-01-20 09:58:51 +0100 |
| commit | 53fe9933fd6c62f3a7f1ed2908a99510c2f27adc (patch) | |
| tree | c30ea24a0651f6e63fdaeea27e57621ca3c19e6c /spec/bundler/runtime/env_helpers_spec.rb | |
| parent | 6fb50434e325dbaf0ae75ade5b47b26f9671a5d2 (diff) | |
Similar optimizations to the ones performed in GH-15907.
- Skip the expensive multi-byte encoding handling for the common
encodings that are known to be safe.
- Use `CheckPath` to save on copying the argument and only scan it for
NULL bytes once.
- Create the return string with rb_enc_str_new instead of rb_str_subseq
as it's going to be a very small string anyway.
This could be optimized a little bit further by searching for both `.` and `dirsep`
in one pass,
```
compare-ruby: ruby 4.1.0dev (2026-01-19T03:51:30Z master 631bf19b37) +PRISM [arm64-darwin25]
built-ruby: ruby 4.1.0dev (2026-01-20T07:33:42Z master 6fb50434e3) +PRISM [arm64-darwin25]
```
| |compare-ruby|built-ruby|
|:----------|-----------:|---------:|
|long | 3.606M| 22.229M|
| | -| 6.17x|
|long_name | 2.254M| 13.416M|
| | -| 5.95x|
|short | 16.488M| 29.969M|
| | -| 1.82x|
Diffstat (limited to 'spec/bundler/runtime/env_helpers_spec.rb')
0 files changed, 0 insertions, 0 deletions
