Skip to content

Commit 6da384d

Browse files
committed
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.
1 parent b3d83f6 commit 6da384d

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

lib/prism/polyfill/scan_byte.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
require "strscan"
44

55
# Polyfill for StringScanner#scan_byte, which didn't exist until Ruby 3.4.
6-
if !(StringScanner.instance_methods.include?(:scan_byte))
6+
if !(StringScanner.method_defined?(:scan_byte))
77
StringScanner.include(
88
Module.new {
99
def scan_byte # :nodoc:

0 commit comments

Comments
 (0)