From 6da384dd0ec505c426dd53d506cd32cb8fb976e3 Mon Sep 17 00:00:00 2001 From: Nobuyoshi Nakada Date: Fri, 14 Nov 2025 10:51:20 +0900 Subject: [PATCH] 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. --- lib/prism/polyfill/scan_byte.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/prism/polyfill/scan_byte.rb b/lib/prism/polyfill/scan_byte.rb index 2def4572c4..9276e509fc 100644 --- a/lib/prism/polyfill/scan_byte.rb +++ b/lib/prism/polyfill/scan_byte.rb @@ -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: