mirror of
https://github.com/pry/pry.git
synced 2022-11-09 12:35:05 -05:00
Code#to_s: don't loop thrice
One loop is enough to complete the task. Signed-off-by: Kyrylo Silin <kyrylosilin@gmail.com>
This commit is contained in:
parent
5ec0bfa3a5
commit
8779d50fd9
1 changed files with 7 additions and 7 deletions
|
@ -304,14 +304,14 @@ class Pry
|
|||
# @return [String] a formatted representation (based on the configuration of
|
||||
# the object).
|
||||
def to_s
|
||||
lines = @lines.map(&:dup).each do |loc|
|
||||
loc.colorize(@code_type) if Pry.color
|
||||
@lines.map { |loc|
|
||||
loc = loc.dup
|
||||
loc.colorize(@code_type) if Pry.color
|
||||
loc.add_line_number(max_lineno_width) if @with_line_numbers
|
||||
loc.add_marker(@marker_lineno) if @with_marker
|
||||
loc.indent(@indentation_num) if @with_indentation
|
||||
end
|
||||
|
||||
lines.map(&:line).join("\n") + "\n"
|
||||
loc.add_marker(@marker_lineno) if @with_marker
|
||||
loc.indent(@indentation_num) if @with_indentation
|
||||
loc.line
|
||||
}.join("\n") + "\n"
|
||||
end
|
||||
|
||||
# Get the comment that describes the expression on the given line number.
|
||||
|
|
Loading…
Add table
Reference in a new issue