Visitar URL original
Use the passed context for to_str checks in Array#join by sampokuokkanen · Pull Request #9964 · jruby/jruby · GitHub
Skip to content

Use the passed context for to_str checks in Array#join - #9964

Merged
headius merged 1 commit into
jruby:masterfrom
sampokuokkanen:array-join-context
Oct 30, 2026
Merged

headius merged 1 commit into
jruby:masterfrom
sampokuokkanen:array-join-context

Conversation

@sampokuokkanen

Copy link
Copy Markdown
Contributor

For each element that is neither a String nor an Array, joinAny called checkStringType(), which looks up the current thread context and its call sites on every element. Check with the context joinAny already has and a call site cached for the loop, as to_ary_checked already is.

Joining 100 Integers or Symbols goes from about 72 to 60 ns per element on arm64-darwin.

This came up from searching for something like ruby/ruby#18610 in JRuby.

For each element that is neither a String nor an Array, joinAny called
checkStringType(), which looks up the current thread context and its
call sites on every element. Check with the context joinAny already has
and a call site cached for the loop, as to_ary_checked already is.

Joining 100 Integers or Symbols goes from about 72 to 60 ns per element
on arm64-darwin.
@headius headius added this to the JRuby 10.1.3.0 milestone Oct 30, 2026
@headius
headius merged commit 62362a2 into jruby:master Oct 30, 2026
144 of 146 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants