Skip to content

Commit 226f932

Browse files
fatkodimadotai2012
andauthored
Use caller_locations to reduce memory allocation (#138)
Co-authored-by: Tai Do <tai.do@partech.com>
1 parent b43a3bb commit 226f932

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

lib/marginalia/comment.rb

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -112,10 +112,12 @@ def self.sidekiq_job
112112
def self.line
113113
Marginalia::Comment.lines_to_ignore ||= DEFAULT_LINES_TO_IGNORE_REGEX
114114

115-
last_line = caller.detect do |line|
116-
line !~ Marginalia::Comment.lines_to_ignore
115+
last_line = caller_locations.detect do |loc|
116+
!loc.path.match?(Marginalia::Comment.lines_to_ignore)
117117
end
118118
if last_line
119+
last_line = last_line.to_s
120+
119121
root = if defined?(Rails) && Rails.respond_to?(:root)
120122
Rails.root.to_s
121123
elsif defined?(RAILS_ROOT)

0 commit comments

Comments
 (0)