Skip to content

Commit

Permalink
Code#to_s: don't loop thrice
Browse files Browse the repository at this point in the history
One loop is enough to complete the task.

Signed-off-by: Kyrylo Silin <kyrylosilin@gmail.com>
  • Loading branch information
kyrylo committed Jan 7, 2013
1 parent 5ec0bfa commit 8779d50
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions lib/pry/code.rb
Expand Up @@ -304,14 +304,14 @@ def max_lineno_width
# @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.
Expand Down

0 comments on commit 8779d50

Please sign in to comment.