Mercurial > hg > octave-nkf
changeset 18284: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 | efaff9f3ca39 |
children | bffa6c8255a9 |
files | libinterp/parse-tree/pt-pr-code.cc |
diffstat | 1 files changed, 2 insertions(+), 6 deletions(-) [+] |
line wrap: on
line diff
--- a/libinterp/parse-tree/pt-pr-code.cc +++ b/libinterp/parse-tree/pt-pr-code.cc @@ -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; }