[Kst] extragear/graphics/kst/kst/datasources/ascii

George Staikos staikos at kde.org
Fri Jun 24 20:58:33 CEST 2005


SVN commit 428634 by staikos:

- save some function calls, especially atof("NaN") repeatedly.
- push variable into the right scope


 M  +7 -5      ascii.cpp  


--- trunk/extragear/graphics/kst/kst/datasources/ascii/ascii.cpp #428633:428634
@@ -18,6 +18,8 @@
 #include "ascii.h"
 #include "asciiconfig.h"
 
+#include <kstmath.h>
+
 #include <kcombobox.h>
 #include <kdebug.h>
 
@@ -284,7 +286,7 @@
   int bufstart, bufread;
   bool new_data = false;
   char tmpbuf[MAXBUFREADLEN+1];
-  char* comment;
+  const char *del = _config->_delimiters.latin1(); // beware
   
   do {
     /* Read the tmpbuffer, starting at row_index[_numFrames] */
@@ -300,7 +302,7 @@
     tmpbuf[bufread] = '\0';
     
     bool is_comment = false, has_dat = false;
-    comment = strpbrk(tmpbuf, _config->_delimiters.latin1());
+    char *comment = strpbrk(tmpbuf, del);
     for (int i = 0; i < bufread; i++) {      
       if (comment == &(tmpbuf[i])) {    
         is_comment = true;
@@ -316,7 +318,7 @@
         _rowIndex[_numFrames] = bufstart + i + 1;
         has_dat = is_comment = false;
         if (comment && comment < &(tmpbuf[i])) {
-          comment = strpbrk(&(tmpbuf[i]), _config->_delimiters.latin1());
+          comment = strpbrk(&(tmpbuf[i]), del);
         }
       } else if (!is_comment && !isspace(tmpbuf[i])) {   
         has_dat = true;
@@ -415,7 +417,7 @@
             if (i_col == col) {
               v[i] = atof(_tmpBuf + ch);
               if (v[i] == 0.0 && !isdigit(_tmpBuf[ch])) {
-                v[i] = atof("NaN");
+                v[i] = NAN;
               }
               break;
             }
@@ -445,7 +447,7 @@
             if (i_col == col) {
               v[i] = atof(_tmpBuf + ch);
               if (v[i] == 0.0 && !isdigit(_tmpBuf[ch])) {
-                v[i] = atof("NaN");
+                v[i] = NAN;
               }
               break;
             }


More information about the Kst mailing list