From 84412ffa1197e58545c943ee10ba949f42c333f3 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Fri, 10 Apr 2026 02:10:33 +0000 Subject: [PATCH 1/2] Bump the github-actions group across 1 directory with 2 updates Bumps the github-actions group with 2 updates in the / directory: [actions/github-script](https://github.com/actions/github-script) and [taiki-e/install-action](https://github.com/taiki-e/install-action). Updates `actions/github-script` from 8.0.0 to 9.0.0 - [Release notes](https://github.com/actions/github-script/releases) - [Commits](https://github.com/actions/github-script/compare/ed597411d8f924073f98dfc5c65a23a2325f34cd...3a2844b7e9c422d3c10d287c895573f7108da1b3) Updates `taiki-e/install-action` from 2.75.1 to 2.75.3 - [Release notes](https://github.com/taiki-e/install-action/releases) - [Changelog](https://github.com/taiki-e/install-action/blob/main/CHANGELOG.md) - [Commits](https://github.com/taiki-e/install-action/compare/80e6af7a2ec7f280fffe2d0a9d3a12a9d11d86e9...b8be7f5e140177087325943c4a8e169d01c59b3d) --- updated-dependencies: - dependency-name: actions/github-script dependency-version: 9.0.0 dependency-type: direct:production update-type: version-update:semver-major dependency-group: github-actions - dependency-name: taiki-e/install-action dependency-version: 2.75.3 dependency-type: direct:production update-type: version-update:semver-patch dependency-group: github-actions ... Signed-off-by: dependabot[bot] --- .github/workflows/pr-playground.yml | 2 +- .github/workflows/zjit-macos.yml | 2 +- .github/workflows/zjit-ubuntu.yml | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/pr-playground.yml b/.github/workflows/pr-playground.yml index 097c14bd5cb758..dc4f075a384293 100644 --- a/.github/workflows/pr-playground.yml +++ b/.github/workflows/pr-playground.yml @@ -29,7 +29,7 @@ jobs: && github.event.workflow_run.event == 'pull_request') }} steps: - - uses: actions/github-script@ed597411d8f924073f98dfc5c65a23a2325f34cd # v8 + - uses: actions/github-script@3a2844b7e9c422d3c10d287c895573f7108da1b3 # v9.0.0 with: github-token: ${{ secrets.GITHUB_TOKEN }} script: | diff --git a/.github/workflows/zjit-macos.yml b/.github/workflows/zjit-macos.yml index 2e736673991aea..888a0ec8009a9f 100644 --- a/.github/workflows/zjit-macos.yml +++ b/.github/workflows/zjit-macos.yml @@ -93,7 +93,7 @@ jobs: rustup install ${{ matrix.rust_version }} --profile minimal rustup default ${{ matrix.rust_version }} - - uses: taiki-e/install-action@80e6af7a2ec7f280fffe2d0a9d3a12a9d11d86e9 # v2.75.1 + - uses: taiki-e/install-action@b8be7f5e140177087325943c4a8e169d01c59b3d # v2.75.3 with: tool: nextest@0.9 if: ${{ matrix.test_task == 'zjit-check' }} diff --git a/.github/workflows/zjit-ubuntu.yml b/.github/workflows/zjit-ubuntu.yml index a0adec6652ac1a..79d1b7bea4558e 100644 --- a/.github/workflows/zjit-ubuntu.yml +++ b/.github/workflows/zjit-ubuntu.yml @@ -119,7 +119,7 @@ jobs: ruby-version: '3.1' bundler: none - - uses: taiki-e/install-action@80e6af7a2ec7f280fffe2d0a9d3a12a9d11d86e9 # v2.75.1 + - uses: taiki-e/install-action@b8be7f5e140177087325943c4a8e169d01c59b3d # v2.75.3 with: tool: nextest@0.9 if: ${{ matrix.test_task == 'zjit-check' }} From 36b0ae025a86b50837e814f7baa7a797184b89d5 Mon Sep 17 00:00:00 2001 From: Jean Boussier Date: Thu, 9 Apr 2026 19:40:36 +0200 Subject: [PATCH 2/2] Add single byte fast path to `File.expand_path` Similar to previous changes to `File.join` & al. ``` compare-ruby: ruby 4.1.0dev (2026-04-09T12:24:09Z master c919778017) +PRISM [arm64-darwin25] built-ruby: ruby 4.1.0dev (2026-04-09T17:42:24Z expand-path-mbenc 4fd047f73c) +PRISM [arm64-darwin25] ``` | |compare-ruby|built-ruby| |:------------|-----------:|---------:| |expand_path | 719.828k| 1.922M| | | -| 2.67x| --- benchmark/file_expand_path.yml | 4 ++++ file.c | 29 ++++++++++++++++++++--------- 2 files changed, 24 insertions(+), 9 deletions(-) create mode 100644 benchmark/file_expand_path.yml diff --git a/benchmark/file_expand_path.yml b/benchmark/file_expand_path.yml new file mode 100644 index 00000000000000..9e503ab0032ccb --- /dev/null +++ b/benchmark/file_expand_path.yml @@ -0,0 +1,4 @@ +prelude: | + # frozen_string_literal: true +benchmark: + expand_path: File.expand_path("../../foo.txt", __FILE__) diff --git a/file.c b/file.c index b4560bea630c03..79d46b2de9670c 100644 --- a/file.c +++ b/file.c @@ -3707,8 +3707,9 @@ skipprefixroot(const char *path, const char *end, rb_encoding *enc) #endif } -char * -rb_enc_path_last_separator(const char *path, const char *end, rb_encoding *enc) + +static char * +enc_path_last_separator(const char *path, const char *end, bool mb_enc, rb_encoding *enc) { char *last = NULL; while (path < end) { @@ -3719,17 +3720,22 @@ rb_enc_path_last_separator(const char *path, const char *end, rb_encoding *enc) last = (char *)tmp; } else { - Inc(path, end, true, enc); + Inc(path, end, mb_enc, enc); } } return last; } +char * +rb_enc_path_last_separator(const char *path, const char *end, rb_encoding *enc) +{ + return enc_path_last_separator(path, end, true, enc); +} static inline char * strrdirsep(const char *path, const char *end, bool mb_enc, rb_encoding *enc) { if (RB_UNLIKELY(mb_enc)) { - return rb_enc_path_last_separator(path, end, enc); + return enc_path_last_separator(path, end, mb_enc, enc); } const char *cursor = end - 1; @@ -4021,7 +4027,12 @@ rb_file_expand_path_internal(VALUE fname, VALUE dname, int abs_mode, int long_na s = StringValuePtr(fname); fend = s + RSTRING_LEN(fname); - enc = rb_enc_get(fname); + enc = rb_str_enc_get(fname); + bool mb_enc = !rb_str_encindex_fastpath(rb_enc_to_index(enc)); + if (!mb_enc && RTEST(dname)) { + mb_enc = !rb_str_encindex_fastpath(rb_enc_to_index(rb_str_enc_get(dname))); + } + BUFINIT(); if (s < fend && s[0] == '~' && abs_mode == 0) { /* execute only if NOT absolute_path() */ @@ -4115,7 +4126,7 @@ rb_file_expand_path_internal(VALUE fname, VALUE dname, int abs_mode, int long_na } else #endif /* defined DOSISH || defined __CYGWIN__ */ - p = chompdirsep(skiproot(buf, p), p, true, enc); + p = chompdirsep(skiproot(buf, p), p, mb_enc, enc); } else { size_t len; @@ -4139,7 +4150,7 @@ rb_file_expand_path_internal(VALUE fname, VALUE dname, int abs_mode, int long_na rb_str_set_len(result, p-buf+1); BUFCHECK(bdiff + 1 >= buflen); p[1] = 0; - root = skipprefix(buf, p+1, true, enc); + root = skipprefix(buf, p+1, mb_enc, enc); b = s; while (s < fend) { @@ -4156,7 +4167,7 @@ rb_file_expand_path_internal(VALUE fname, VALUE dname, int abs_mode, int long_na /* We must go back to the parent */ char *n; *p = '\0'; - if (!(n = strrdirsep(root, p, true, enc))) { + if (!(n = strrdirsep(root, p, mb_enc, enc))) { *p = '/'; } else { @@ -4219,7 +4230,7 @@ rb_file_expand_path_internal(VALUE fname, VALUE dname, int abs_mode, int long_na } } #endif /* __APPLE__ */ - Inc(s, fend, true, enc); + Inc(s, fend, mb_enc, enc); break; } }