Skip to content

Commit 40d6610

Browse files
committed
Detect multiple lines output simplify
The old implementation performance test code: require 'objspace' puts "%.5g MB" % (ObjectSpace.memsize_of_all * 0.001 * 0.001) /\A.*\Z/ !~ ('abc' * 20_000_000) puts "%.5g MB" % (ObjectSpace.memsize_of_all * 0.001 * 0.001) and run `time test.rb`: 2.5868 MB 62.226 MB real 0m1.307s user 0m0.452s sys 0m0.797s The new implementation performance test code: require 'objspace' puts "%.5g MB" % (ObjectSpace.memsize_of_all * 0.001 * 0.001) ('abc' * 20_000_000).include?("\n") puts "%.5g MB" % (ObjectSpace.memsize_of_all * 0.001 * 0.001) and run `time test.rb`: 2.5861 MB 62.226 MB real 0m0.132s user 0m0.088s sys 0m0.042s
1 parent cc42036 commit 40d6610

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

lib/irb.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -738,7 +738,7 @@ def prompt(prompt, ltype, indent, line_no) # :nodoc:
738738

739739
def output_value # :nodoc:
740740
str = @context.inspect_last_value
741-
multiline_p = /\A.*\Z/ !~ str
741+
multiline_p = str.include?("\n")
742742
if multiline_p && @context.newline_before_multiline_output?
743743
printf @context.return_format, "\n#{str}"
744744
else

0 commit comments

Comments
 (0)