😸
[Feature #20429] パフォーマンスに影響があるメソッドを再定義すると警告を出す提案
[Feature #20429] Emit a performance warning when specially optimized core methods are redefined
- パフォーマンスに影響があるメソッドを再定義したときに警告を出すようにする提案
- 具体的には以下のメソッドが提示されています
-
Integer:#+, #-, #*, #/, #%, #<, #>, #<=, #>= -
Float:#+, #-, #*, #/, #<, #>, #<=, #>= -
String:#freeze, #size, #length, #empty?, #+, #succ, #%, #-@ -
Array:#size, #length, #empty?, #hash -
Hash:#size, #length, #empty?, #[], #[]=
-
- この対応は承認されて Ruby 3.4 から
-W:performanceが有効な場合に警告がでるようになります
Warning[:performance] = true
# warning: Redefining 'String#freeze' disables interpreter and JIT optimizations
class String
def freeze
super
end
end
Discussion