# HG changeset patch # User Rik # Date 1390642695 28800 # Node ID 5b7b12e16523c1c5c41d28e36204b943f925a7ba # Parent 6e334411152245fa545e411b92be912653af5964 Speed up dbtype by 10X by using line-oriented input. * debug.cc (do_dbtype): Use getline() rather than get (ch) when reading m-file. diff -r 6e3344111522 -r 5b7b12e16523 libinterp/corefcn/debug.cc --- a/libinterp/corefcn/debug.cc Fri Jan 24 22:17:29 2014 -0500 +++ b/libinterp/corefcn/debug.cc Sat Jan 25 01:38:15 2014 -0800 @@ -922,30 +922,16 @@ if (fs) { - char ch; int line = 1; - bool isnewline = true; + std::string text; - // FIXME: Why not use line-oriented input here [getline()]? - while (fs.get (ch) && line <= end) - { - if (isnewline && line >= start) - { - os << line << "\t"; - isnewline = false; - } - - if (line >= start) - { - os << ch; - } - - if (ch == '\n') - { - line++; - isnewline = true; - } - } + while (std::getline (fs, text) && line <= end) + { + if (line >= start) + os << line << "\t" << text << "\n"; + + line++; + } } else os << "dbtype: unable to open '" << ff << "' for reading!\n";