diff options
| author | Schneems <richard.schneeman+foo@gmail.com> | 2026-01-20 15:32:33 -0600 |
|---|---|---|
| committer | git <svn-admin@ruby-lang.org> | 2026-01-21 15:57:38 +0000 |
| commit | 54fa9c81e13039ec92f5b2132a65e64092d81ad7 (patch) | |
| tree | 33cea3e6a49cbf464924a0ce97b5a4c9a696df87 /spec/ruby/core/array/shared/push.rb | |
| parent | 8aedb89681c42a8d6169ff1950135f841cd578f1 (diff) | |
[ruby/syntax_suggest] Refactor multi-prism version logic
The reason this logic for different methods branches in the class instead of internally was to be eagerly aggressive about runtime performance. This code is currently only used once for the document where it's invoked ~N times (where N is number of lines):
```ruby
module SyntaxSuggest
class CleanDocument
# ...
def join_trailing_slash!
trailing_groups = @document.select(&:trailing_slash?).map do |code_line|
take_while_including(code_line.index..) { |x| x.trailing_slash? }
end
join_groups(trailing_groups)
self
end
```
Since this is not currently a hot-spot I think merging the branches and using a case statement is a reasonable tradeoff and avoids the need to do specific version testing.
An alternative idea was presented in #241 of behavior-based testing for branch logic (which I would prefer), however, calling the code triggered requiring a `DelegateClass` when the `syntax_suggest/api` is being required.
https://github.com/ruby/syntax_suggest/commit/ab122c455f
Diffstat (limited to 'spec/ruby/core/array/shared/push.rb')
0 files changed, 0 insertions, 0 deletions
