summaryrefslogtreecommitdiff
path: root/include/ruby/internal/method.h
diff options
context:
space:
mode:
authorJean Boussier <byroot@ruby-lang.org>2023-11-20 13:48:34 +0100
committerJean Boussier <jean.boussier@gmail.com>2023-11-20 14:33:20 +0100
commit83c385719d95c178790e52f78e2b247d1476eb5e (patch)
tree9dae5511963e8d129ce87bbd8d8cd4a8dbe1c29d /include/ruby/internal/method.h
parent701b0650de8a5b1436ce1abc65e0fcc2be480c2d (diff)
Specialize String#dup
`String#+@` is 2-3 times faster than `String#dup` because it can directly go through `rb_str_dup` instead of using the generic much slower `rb_obj_dup`. This fact led to the existance of the ugly `Performance/UnfreezeString` rubocop performance rule that encourage users to rewrite the much more readable and convenient `"foo".dup` into the ugly `(+"foo")`. Let's make that rubocop rule useless. ``` compare-ruby: ruby 3.3.0dev (2023-11-20T02:02:55Z master 701b0650de) [arm64-darwin22] last_commit=[ruby/prism] feat: add encoding for IBM865 (https://github.com/ruby/prism/pull/1884) built-ruby: ruby 3.3.0dev (2023-11-20T12:51:45Z faster-str-lit-dup 6b745bbc5d) [arm64-darwin22] warming up.. | |compare-ruby|built-ruby| |:------|-----------:|---------:| |uplus | 16.312M| 16.332M| | | -| 1.00x| |dup | 5.912M| 16.329M| | | -| 2.76x| ```
Diffstat (limited to 'include/ruby/internal/method.h')
0 files changed, 0 insertions, 0 deletions