[Numpy-svn] r6280 - branches/fix_float_format/numpy/core/src

numpy-svn@scip... numpy-svn@scip...
Tue Dec 30 15:14:14 CST 2008


Author: ptvirtan
Date: 2008-12-30 15:14:04 -0600 (Tue, 30 Dec 2008)
New Revision: 6280

Modified:
   branches/fix_float_format/numpy/core/src/npy_format.c
Log:
Speed up NumPyOS_ascii_strtod

Modified: branches/fix_float_format/numpy/core/src/npy_format.c
===================================================================
--- branches/fix_float_format/numpy/core/src/npy_format.c	2008-12-30 20:37:30 UTC (rev 6279)
+++ branches/fix_float_format/numpy/core/src/npy_format.c	2008-12-30 21:14:04 UTC (rev 6280)
@@ -303,10 +303,14 @@
 NumPyOS_ascii_strtod(const char *s, char** endptr)
 {
     char buffer[FLOAT_FORMATBUFLEN+1];
-    char *p;
+    const char *p;
     size_t n;
     double result;
 
+    while (NumPyOS_ascii_isspace(*s)) {
+        ++s;
+    }
+
     /* ## 1
      *
      * At least Python versions <= 2.5.2 and <= 2.6.1
@@ -315,10 +319,8 @@
      * under foreign locale.
      */
     p = s;
-    while ((*p >= '0' && *p <= '9') || *p == '+' || *p == '-'
-           || NumPyOS_ascii_isspace(*p)) {
-        ++p;
-    }
+    if (*p == '+' || *p == '-') ++p;
+    while (*p >= '0' && *p <= '9') ++p;
     if (*p == ',') {
         n = (size_t)(p - s);
         if (n > FLOAT_FORMATBUFLEN)



More information about the Numpy-svn mailing list