[Kst] [Bug 106008] NaN values should not be skipped while importing
data from ASCII file
Andrew Walker
arwalker at sumusltd.com
Tue Jun 21 23:01:58 CEST 2005
------- You are receiving this mail because: -------
You are the assignee for the bug, or are watching the assignee.
http://bugs.kde.org/show_bug.cgi?id=106008
------- Additional Comments From arwalker sumusltd com 2005-06-21 23:01 -------
SVN commit 427790 by arwalker:
CCMAIL:106008 bugs kde org ascii datasource now runs faster than the original version, by about 40 percent. The only difference between the two is that a line such as 'X Y Z' would previously have been skipped, but is now treated (correctly I believe) as '0 0 0'
M +12 -5 ascii.cpp
--- trunk/extragear/graphics/kst/kst/datasources/ascii/ascii.cpp #427789:427790
@ -280,10 +280,12 @
}
_valid = true;
-
+
int bufstart, bufread;
bool new_data = false;
- char tmpbuf[MAXBUFREADLEN];
+ char tmpbuf[MAXBUFREADLEN+1];
+ char* comment;
+
do {
/* Read the tmpbuffer, starting at row_index[_numFrames] */
if (_byteLength - _rowIndex[_numFrames] > MAXBUFREADLEN) {
@ -295,10 +297,12 @
bufstart = _rowIndex[_numFrames];
file.at(bufstart); // expensive?
file.readBlock(tmpbuf, bufread);
-
+ tmpbuf[bufread] = '\0';
+
bool is_comment = false, has_dat = false;
+ comment = strpbrk(tmpbuf, _config->_delimiters.latin1());
for (int i = 0; i < bufread; i++) {
- if (_config->_delimiters.contains(tmpbuf[i])) {
+ if (comment == &(tmpbuf[i])) {
is_comment = true;
} else if (tmpbuf[i] == '\n' || tmpbuf[i] == '\r') {
if (has_dat) {
@ -311,12 +315,15 @
}
_rowIndex[_numFrames] = bufstart + i + 1;
has_dat = is_comment = false;
+ if (comment && comment < &(tmpbuf[i])) {
+ comment = strpbrk(&(tmpbuf[i]), _config->_delimiters.latin1());
+ }
} else if (!is_comment && !isspace(tmpbuf[i])) {
has_dat = true;
}
}
} while (bufread == MAXBUFREADLEN);
-
+
file.close();
updateNumFramesScalar();
More information about the Kst
mailing list