]> git.ipfire.org Git - thirdparty/sqlite.git/commitdiff
Performance enhancement in sqlite3AtoF(). About 8% faster.
authordrh <drh@noemail.net>
Sat, 25 May 2019 18:17:53 +0000 (18:17 +0000)
committerdrh <drh@noemail.net>
Sat, 25 May 2019 18:17:53 +0000 (18:17 +0000)
FossilOrigin-Name: 81721aa54587e20d031d528fb6b74d91671a6e950fa926dc63f4284466e70f0e

manifest
manifest.uuid
src/util.c

index 257aeea9d7b287737caef11cc853e67374b040b7..22c51be6ab08729ad48f1811ff24237310a20712 100644 (file)
--- a/manifest
+++ b/manifest
@@ -1,5 +1,5 @@
-C Use\s"long\sdouble"\sliterals\sto\sinitialize\san\sarray\sof\s"long\sdouble"\sobjects.
-D 2019-05-25T17:41:07.575
+C Performance\senhancement\sin\ssqlite3AtoF().\s\sAbout\s8%\sfaster.
+D 2019-05-25T18:17:53.260
 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1
 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea
 F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724
@@ -592,7 +592,7 @@ F src/trigger.c bb034c08eca111e66a19cda045903a12547c1be2294b5570d794b869d9c44a73
 F src/update.c 3cb9150d2cf661d938e2f1b1749945f3faa767f88febdb739ab1793bbf895ff2
 F src/upsert.c 0dd81b40206841814d46942a7337786932475f085716042d0cb2fc7791bf8ca4
 F src/utf.c 2f0fac345c7660d5c5bd3df9e9d8d33d4c27f366bcfb09e07443064d751a0507
-F src/util.c 94464ad0f6d893b439f773aa6acfb9c3220fd251f5ffd025529e290de6a1e2f7
+F src/util.c 2f07256354b58053c20045fa5b3d4bc3884dfa4d393a66c983cfea115d8253dc
 F src/vacuum.c 82dcec9e7b1afa980288718ad11bc499651c722d7b9f32933c4d694d91cb6ebf
 F src/vdbe.c 0380e94736e0b5a0717460d1d3546ae4b1338d0fe7ea07674633d1fd9a5fc42b
 F src/vdbe.h 712bca562eaed1c25506b9faf9680bdc75fc42e2f4a1cd518d883fa79c7a4237
@@ -1829,7 +1829,7 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93
 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc
 F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e
 F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0
-P b84e7057c05338347b4267f7ccc1d7b9b6d4e9a941ce8b76bf2c27c26772000c
-R 93de9e77865611bdbf18a7a1be8bf013
+P 2e2ebad3ab636c4c65814ad41d417b105be8e254d609d0e08fbba4c5bd107bf3
+R ef9208359f9605c768184cd8045692e9
 U drh
-Z 961c5c6f7eb3026439aac298d02352ba
+Z f6f659f82b7441453c2104f0c0b3b1fb
index c520f7ced3c1794448358b89f3e6c77e2652abee..776837a3361bf50bdc46fdd748d65a1defe75adb 100644 (file)
@@ -1 +1 @@
-2e2ebad3ab636c4c65814ad41d417b105be8e254d609d0e08fbba4c5bd107bf3
\ No newline at end of file
+81721aa54587e20d031d528fb6b74d91671a6e950fa926dc63f4284466e70f0e
\ No newline at end of file
index dabff991a2819d17790fbc397353d6973e9e51de..a59a2d240ecebe68c0dd73bddfcb0843e126512d 100644 (file)
@@ -423,7 +423,7 @@ int sqlite3AtoF(const char *z, double *pResult, int length, u8 enc){
   int e = 0;       /* exponent */
   int eValid = 1;  /* True exponent is either not used or is well-formed */
   double result;
-  int nDigits = 0;
+  int nDigit = 0;  /* Number of digits processed */
   int nonNum = 0;  /* True if input contains UTF16 with high byte non-zero */
 
   assert( enc==SQLITE_UTF8 || enc==SQLITE_UTF16LE || enc==SQLITE_UTF16BE );
@@ -454,14 +454,15 @@ int sqlite3AtoF(const char *z, double *pResult, int length, u8 enc){
   }
 
   /* copy max significant digits to significand */
-  while( z<zEnd && sqlite3Isdigit(*z) && s<((LARGEST_INT64-9)/10) ){
+  while( z<zEnd && sqlite3Isdigit(*z) ){
     s = s*10 + (*z - '0');
-    z+=incr; nDigits++;
+    z+=incr; nDigit++;
+    if( s>=((LARGEST_INT64-9)/10) ){
+      /* skip non-significant significand digits
+      ** (increase exponent by d to shift decimal left) */
+      while( z<zEnd && sqlite3Isdigit(*z) ){ z+=incr; d++; }
+    }
   }
-
-  /* skip non-significant significand digits
-  ** (increase exponent by d to shift decimal left) */
-  while( z<zEnd && sqlite3Isdigit(*z) ){ z+=incr; nDigits++; d++; }
   if( z>=zEnd ) goto do_atof_calc;
 
   /* if decimal point is present */
@@ -473,8 +474,9 @@ int sqlite3AtoF(const char *z, double *pResult, int length, u8 enc){
       if( s<((LARGEST_INT64-9)/10) ){
         s = s*10 + (*z - '0');
         d--;
+        nDigit++;
       }
-      z+=incr; nDigits++;
+      z+=incr;
     }
   }
   if( z>=zEnd ) goto do_atof_calc;
@@ -581,7 +583,7 @@ do_atof_calc:
   *pResult = result;
 
   /* return true if number and no extra non-whitespace chracters after */
-  return z==zEnd && nDigits>0 && eValid && nonNum==0;
+  return z==zEnd && nDigit>0 && eValid && nonNum==0;
 #else
   return !sqlite3Atoi64(z, pResult, length, enc);
 #endif /* SQLITE_OMIT_FLOATING_POINT */