[Kst] branches/work/kst/portto4/kst/src/datasources/ascii
Peter Kümmel
syntheticpp at gmx.net
Tue Jan 25 18:57:14 CET 2011
SVN commit 1217088 by kuemmel:
another speedup:
msvc : 3.7s -> 2.9s
mingw: 3.4s -> 3.1s
M +4 -4 asciisource.cpp
M +11 -0 asciisource.h
M +7 -3 kst_atof.cpp
M +1 -0 kst_atof.h
--- branches/work/kst/portto4/kst/src/datasources/ascii/asciisource.cpp #1217087:1217088
@@ -552,15 +552,15 @@
}
+
//-------------------------------------------------------------------------------------------
void AsciiSource::toDouble(const LexicalCast& lexc, const char* buffer, int bufread, int ch, double* v, int row)
{
- const char* here = &buffer[ch];
- if ( buffer[ch] == '-'
+ if ( isDigit(buffer[ch])
+ || buffer[ch] == '-'
|| buffer[ch] == '.'
|| buffer[ch] == '+'
- || isdigit((unsigned char)buffer[ch])
- || isspace((unsigned char)buffer[ch])) {
+ || isWhiteSpace(buffer[ch])) {
*v = lexc.toDouble(&buffer[0] + ch);
} else if ( ch + 2 < bufread
&& tolower(buffer[ch]) == 'i'
--- branches/work/kst/portto4/kst/src/datasources/ascii/asciisource.h #1217087:1217088
@@ -137,6 +137,14 @@
}
};
+ struct IsDigit {
+ IsDigit() {
+ }
+ inline bool operator()(const char c) const {
+ return (c >= 48) && (c <= 57) ? true : false;
+ }
+ };
+
struct IsCharacter {
IsCharacter(char c) : character(c) {
}
@@ -181,6 +189,9 @@
void toDouble(const LexicalCast& lexc, const char* buffer, int bufread, int ch, double* v, int row);
+ const IsDigit isDigit;
+ const IsWhiteSpace isWhiteSpace;
+
// TODO remove
friend class DataInterfaceAsciiString;
friend class DataInterfaceAsciiVector;
--- branches/work/kst/portto4/kst/src/datasources/ascii/kst_atof.cpp #1217087:1217088
@@ -3,6 +3,7 @@
#include "kst_atof.h"
+
#include <math.h>
#include <ctype.h>
@@ -11,6 +12,9 @@
#define LOGHUGE 39
+inline bool LexicalCast::isDigit(const char c) const {
+ return (c >= 48) && (c <= 57) ? true : false;
+}
#ifdef KST_USE_KST_ATOF
double LexicalCast::toDouble(const char* signedp) const
@@ -35,7 +39,7 @@
exp = 0;
fl = 0;
nd = 0;
- while ((c = *p++), isdigit(c)) {
+ while ((c = *p++), isDigit(c)) {
if (fl<big)
fl = 10*fl + (c-'0');
else
@@ -44,7 +48,7 @@
}
if (c == _separator) {
- while ((c = *p++), isdigit(c)) {
+ while ((c = *p++), isDigit(c)) {
if (fl<big) {
fl = 10*fl + (c-'0');
exp--;
@@ -63,7 +67,7 @@
else
--p;
- while ((c = *p++), isdigit(c)) {
+ while ((c = *p++), isDigit(c)) {
eexp = 10*eexp+(c-'0');
}
if (negexp<0)
--- branches/work/kst/portto4/kst/src/datasources/ascii/kst_atof.h #1217087:1217088
@@ -23,6 +23,7 @@
bool _useDot;
char _separator;
QByteArray _originalLocal;
+ bool isDigit(const char) const;
};
More information about the Kst
mailing list