Skip to content

Commit

Permalink
Use caller_locations to reduce memory allocation (#138)
Browse files Browse the repository at this point in the history
Co-authored-by: Tai Do <[email protected]>
  • Loading branch information
fatkodima and dotai2012 authored Jan 10, 2024
1 parent b43a3bb commit 226f932
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions lib/marginalia/comment.rb
Original file line number Diff line number Diff line change
Expand Up @@ -112,10 +112,12 @@ def self.sidekiq_job
def self.line
Marginalia::Comment.lines_to_ignore ||= DEFAULT_LINES_TO_IGNORE_REGEX

last_line = caller.detect do |line|
line !~ Marginalia::Comment.lines_to_ignore
last_line = caller_locations.detect do |loc|
!loc.path.match?(Marginalia::Comment.lines_to_ignore)
end
if last_line
last_line = last_line.to_s

root = if defined?(Rails) && Rails.respond_to?(:root)
Rails.root.to_s
elsif defined?(RAILS_ROOT)
Expand Down

0 comments on commit 226f932

Please sign in to comment.