diff libinterp/parse-tree/pt-pr-code.cc @ 18259:c6858f725afe

Use std::string rather than for loop to generate blank string for indentation. * pt-pr-code.cc (tree_print_code::indent): Use std::string constructor to generate a blank string rather than for loop for ~7% performance improvement.
author Rik <rik@octave.org>
date Sat, 11 Jan 2014 21:42:57 -0800
parents 97e49b588f5d
children 75d7cde2dda4
line wrap: on
line diff
--- a/libinterp/parse-tree/pt-pr-code.cc	Sat Jan 11 17:20:38 2014 -0500
+++ b/libinterp/parse-tree/pt-pr-code.cc	Sat Jan 11 21:42:57 2014 -0800
@@ -1200,10 +1200,7 @@
     }
 }
 
-// Each print_code() function should call this before printing
-// anything.
-//
-// This doesn't need to be fast, but isn't there a better way?
+// Each print_code() function should call this before printing anything.
 
 void
 tree_print_code::indent (void)
@@ -1214,8 +1211,7 @@
     {
       os << prefix;
 
-      for (int i = 0; i < curr_print_indent_level; i++)
-        os << " ";
+      os << std::string (curr_print_indent_level, ' ');
 
       beginning_of_line = false;
     }