From 559fea324e9882b259f3e4f49a178d0cd3564216 Mon Sep 17 00:00:00 2001 From: Jeremy Evans Date: Thu, 4 Apr 2024 11:45:41 -0700 Subject: [PATCH] Add RUBY_STDLIB constant to CallerLogging module This avoids unnecessary work inside the caller.find loop. --- lib/sequel/extensions/caller_logging.rb | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/lib/sequel/extensions/caller_logging.rb b/lib/sequel/extensions/caller_logging.rb index 9071c2dc09..70e74dad94 100644 --- a/lib/sequel/extensions/caller_logging.rb +++ b/lib/sequel/extensions/caller_logging.rb @@ -36,6 +36,7 @@ module Sequel module CallerLogging SEQUEL_LIB_PATH = (File.expand_path('../../..', __FILE__) + '/').freeze + RUBY_STDLIB = RbConfig::CONFIG["rubylibdir"] # A regexp of caller lines to ignore, in addition to internal Sequel and Ruby code. attr_accessor :caller_logging_ignore @@ -59,7 +60,7 @@ def external_caller_for_log ignore = caller_logging_ignore c = caller.find do |line| !(line.start_with?(SEQUEL_LIB_PATH) || - line.start_with?(RbConfig::CONFIG["rubylibdir"]) || + line.start_with?(RUBY_STDLIB) || (ignore && line =~ ignore)) end