[Kst] kdeextragear-2/kst/kst/datasources/ascii

George Staikos staikos at kde.org
Thu Mar 3 06:27:38 CET 2005


CVS commit by staikos: 

Another place where comment delimiters were hardcoded, and significantly
reduce the readField loop in cpu cycles (one less condition, and no memset())


  M +7 -14     ascii.cpp   1.36


--- kdeextragear-2/kst/kst/datasources/ascii/ascii.cpp  #1.35:1.36
@@ -215,24 +215,17 @@ int AsciiSource::readField(double *v, co
   file.readBlock(tmpbuf, bufread);
 
-  // FIXME: I don't see why this was changed to memset() instead of just
-  //        setting the required elements to 0 inline when required, as it
-  //        did before.
-  memset( v, 0, n * sizeof( double ) );
-
   for (int i = 0; i < n; i++, s++) {
-    bool done = false;
     bool incol = false;
     int i_col = 0;
-    for (int ch = _rowIndex[s] - bufstart; !done && ch < bufread; ch++) {
+    v[i] = 0.0;
+    for (int ch = _rowIndex[s] - bufstart; ch < bufread; ++ch) {
       if (isspace(tmpbuf[ch])) {
-        if (tmpbuf[ch] == '\n' || tmpbuf[ch] == '\r' ) {
-          done = true;
+        if (tmpbuf[ch] == '\n' || tmpbuf[ch] == '\r') {
+          break;
         } else {
           incol = false;
         }
-      } else if (tmpbuf[ch] == '#' || tmpbuf[ch] == '!' ||
-          tmpbuf[ch] == '/' || tmpbuf[ch] == ';' ||
-          tmpbuf[ch] == 'c') {
-        done = true;
+      } else if (_config->_delimiters.contains(tmpbuf[ch])) {
+        break;
       } else {
         if (!incol) {
@@ -240,6 +233,6 @@ int AsciiSource::readField(double *v, co
           i_col++;
           if (i_col == col) {
-            done = true;
             v[i] = atof(tmpbuf + ch);
+            break;
           }
         }




More information about the Kst mailing list