Skip to content

Commit

Permalink
+ Optimize Range#column_range
Browse files Browse the repository at this point in the history
This avoid creating 4 temporary objects needlessly
  • Loading branch information
marcandre committed Sep 15, 2020
1 parent c25585d commit be6cde6
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions lib/parser/source/range.rb
Expand Up @@ -112,11 +112,11 @@ def last_column
# @raise RangeError
#
def column_range
if self.begin.line != self.end.line
if line != last_line
raise RangeError, "#{self.inspect} spans more than one line"
end

self.begin.column...self.end.column
column...last_column
end

##
Expand Down

0 comments on commit be6cde6

Please sign in to comment.