changeset 18386:5b7b12e16523

Speed up dbtype by 10X by using line-oriented input. * debug.cc (do_dbtype): Use getline() rather than get (ch) when reading m-file.
author Rik <rik@octave.org>
date Sat, 25 Jan 2014 01:38:15 -0800
parents 6e3344111522
children ed1e63425f79
files libinterp/corefcn/debug.cc
diffstat 1 files changed, 8 insertions(+), 22 deletions(-) [+]
line wrap: on
line diff
--- 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";