mirror of
https://github.com/ruby/ruby.git
synced 2026-01-26 12:14:51 +00:00
[ruby/prism] Use method_defined? instead of instance_methods.include?
While the latter creates an intermediate array of all method names including all ancestors, the former just traverse the inheritance chain and can stop if found once. https://github.com/ruby/prism/commit/6da384dd0e
This commit is contained in:
parent
f4b6a5191c
commit
0e604623d8
@ -3,7 +3,7 @@
|
||||
require "strscan"
|
||||
|
||||
# Polyfill for StringScanner#scan_byte, which didn't exist until Ruby 3.4.
|
||||
if !(StringScanner.instance_methods.include?(:scan_byte))
|
||||
if !(StringScanner.method_defined?(:scan_byte))
|
||||
StringScanner.include(
|
||||
Module.new {
|
||||
def scan_byte # :nodoc:
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user