[Kst] branches/work/kst/portto4/kst/src/datasources/ascii

Peter Kümmel syntheticpp at gmx.net
Tue Jan 25 11:53:15 CET 2011


SVN commit 1216987 by kuemmel:

start optimizing internalDataSourceUpdate

 M  +13 -5     asciisource.cpp  
 M  +2 -0      asciisource.h  


--- branches/work/kst/portto4/kst/src/datasources/ascii/asciisource.cpp #1216986:1216987
@@ -334,8 +334,18 @@
     const char* bufferData = buffer.data();
 #endif
 
+    findDataRows(buffer, bufstart, bufread, del, new_data);
+    
+  } while ((bufread == MAXBUFREADLEN)); // && (!first_read));
+
+  return (forceUpdate ? Updated : (new_data ? Updated : NoChange));
+}
+
+
+int AsciiSource::findDataRows(const char* buffer, int bufstart, int bufread, const char *del, bool& new_data)
+{
     bool is_comment = false, has_dat = false;
-    char *comment = strpbrk(const_cast<char*>(bufferData), del);
+  char *comment = strpbrk(const_cast<char*>(buffer), del);
     for (int i = 0; i < bufread; i++) {
       if (comment == &(buffer[i])) {
         is_comment = true;
@@ -343,7 +353,7 @@
         if (has_dat) {
           ++_numFrames;
           if (_numFrames >= _rowIndex.size()) {
-            _rowIndex.resize(_rowIndex.size() + 32768);
+            _rowIndex.resize(_rowIndex.size() + MAXBUFREADLEN);
             if (_numFrames >= _rowIndex.size()) {
               // TODO where could we report an error;
               return NoChange;
@@ -361,9 +371,7 @@
         has_dat = true;
       }      
     }
-  } while ((bufread == MAXBUFREADLEN)); // && (!first_read));
-
-  return (forceUpdate ? Updated : (new_data ? Updated : NoChange));
+  return 0;
 }
 
 
--- branches/work/kst/portto4/kst/src/datasources/ascii/asciisource.h #1216986:1216987
@@ -103,6 +103,8 @@
     int readFromFile(QFile&, T& buffer, int start, int numberOfBytes, int maximalBytes = -1);
 
 
+    int findDataRows(const char* buffer, int bufstart, int bufread, const char *del, bool& new_data);
+
     // column and comment delimiter functions
 
     struct AlwaysTrue {


More information about the Kst mailing list