From: drh <> Date: Sat, 21 Feb 2026 00:20:29 +0000 (+0000) Subject: Small performance increase and size reduction in sqlite3FpDecode() by using X-Git-Tag: version-3.52.0~47^2~5 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=aec283385ef9969198df61136e5171c63ffd3b4d;p=thirdparty%2Fsqlite.git Small performance increase and size reduction in sqlite3FpDecode() by using local variables instead of structure elements. FossilOrigin-Name: b4c378bba582205aa676e45b21ffa17ad6199e2a017ec73cf41a0243f693b589 --- diff --git a/manifest b/manifest index 30469cdd11..d449f79dbe 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Inconsequential\schanges\sto\sfloating-point\sconversion,\samounting\sto\smere\ncode\scleanup\sto\said\scomprehension. -D 2026-02-20T20:43:25.912 +C Small\sperformance\sincrease\sand\ssize\sreduction\sin\ssqlite3FpDecode()\sby\susing\nlocal\svariables\sinstead\sof\sstructure\selements. +D 2026-02-21T00:20:29.013 F .fossil-settings/binary-glob 61195414528fb3ea9693577e1980230d78a1f8b0a54c78cf1b9b24d0a409ed6a x F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea @@ -803,7 +803,7 @@ F src/trigger.c a40440614bdf523090cc07223f4878f7e3c892bcd1a13afe18f90190daa5945d F src/update.c 3e5e7ff66fa19ebe4d1b113d480639a24cc1175adbefabbd1a948a07f28e37cf F src/upsert.c 215328c3f91623c520ec8672c44323553f12caeb4f01b1090ebdca99fdf7b4f1 F src/utf.c 7267c3fb9e2467020507601af3354c2446c61f444387e094c779dccd5ca62165 -F src/util.c 64c047521e35adc402e6f2a8dcd20732392c02641418becfc4387a1c02f5e042 +F src/util.c 2578230d8c15e11cb86b7e6c4c069e5ea880a058d1d9aa25887fb607ac6942cd F src/vacuum.c d3d35d8ae893d419ade5fa196d761a83bddcbb62137a1a157ae751ef38b26e82 F src/vdbe.c 5328c99dd256ee8132383565a86e253543a85daccfd7477c52f20bac6b385a7f F src/vdbe.h 966d0677a540b7ea6549b7c4e1312fc0d830fce3a235a58c801f2cc31cf5ecf9 @@ -2195,8 +2195,8 @@ F tool/warnings-clang.sh bbf6a1e685e534c92ec2bfba5b1745f34fb6f0bc2a362850723a9ee F tool/warnings.sh d924598cf2f55a4ecbc2aeb055c10bd5f48114793e7ba25f9585435da29e7e98 F tool/win/sqlite.vsix deb315d026cc8400325c5863eef847784a219a2f F tool/winmain.c 00c8fb88e365c9017db14c73d3c78af62194d9644feaf60e220ab0f411f3604c -P cb24edf1afc3f9083a4963c5fe232933eccc7c0cb8872aa5fcd336d226b885ef -R 5dc7d1cf9df5b4fd3583425b84bcab00 +P 6d9c29123b6b143b0f7c8f5d018f170c72edfc5b1a4d67edd45e5552def2af6c +R ab113b7f537cba0046252b74a0cfbdbd U drh -Z a28f337e825428b6e4dfea35f10cb54e +Z eb44db8829fa7401363a7a2fe662819e # Remove this line to create a well-formed Fossil manifest. diff --git a/manifest.uuid b/manifest.uuid index f7d89da182..fa0737e469 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -6d9c29123b6b143b0f7c8f5d018f170c72edfc5b1a4d67edd45e5552def2af6c +b4c378bba582205aa676e45b21ffa17ad6199e2a017ec73cf41a0243f693b589 diff --git a/src/util.c b/src/util.c index c39a1da16b..e0de0abf07 100644 --- a/src/util.c +++ b/src/util.c @@ -1174,9 +1174,10 @@ int sqlite3Atoi(const char *z){ ** The p->z[] array is *not* zero-terminated. */ void sqlite3FpDecode(FpDecode *p, double r, int iRound, int mxRound){ - int i; + int i, n; u64 v; int e, exp = 0; + char *zBuf; p->isSpecial = 0; p->z = p->zBuf; @@ -1206,9 +1207,9 @@ void sqlite3FpDecode(FpDecode *p, double r, int iRound, int mxRound){ } v &= 0x000fffffffffffffULL; if( e==0 ){ - int n = countLeadingZeros(v); - v <<= n; - e = -1074 - n; + int nn = countLeadingZeros(v); + v <<= nn; + e = -1074 - nn; }else{ v = (v<<11) | U64_BIT(63); e -= 1086; @@ -1217,38 +1218,39 @@ void sqlite3FpDecode(FpDecode *p, double r, int iRound, int mxRound){ /* Extract significant digits. */ i = sizeof(p->zBuf)-1; + zBuf = p->zBuf; assert( v>0 ); while( v>=10 ){ int kk = (v%100)*2; assert( TWO_BYTE_ALIGNMENT(&sqlite3DigitPairs.a[kk]) ); - assert( TWO_BYTE_ALIGNMENT(&p->zBuf[i-1]) ); - *(u16*)(&p->zBuf[i-1]) = *(u16*)&sqlite3DigitPairs.a[kk]; + assert( TWO_BYTE_ALIGNMENT(&zBuf[i-1]) ); + *(u16*)(&zBuf[i-1]) = *(u16*)&sqlite3DigitPairs.a[kk]; i -= 2; v /= 100; } if( v ){ assert( v<10 ); - p->zBuf[i--] = v + '0'; + zBuf[i--] = v + '0'; } assert( i>=0 && izBuf)-1 ); - p->n = sizeof(p->zBuf) - 1 - i; - assert( p->n>0 ); - assert( p->nzBuf) ); - testcase( p->n==sizeof(p->zBuf)-1 ); - p->iDP = p->n + exp; + n = sizeof(p->zBuf) - 1 - i; + assert( n>0 ); + assert( nzBuf) ); + testcase( n==sizeof(p->zBuf)-1 ); + p->iDP = n + exp; if( iRound<=0 ){ iRound = p->iDP - iRound; - if( iRound==0 && p->zBuf[i+1]>='5' ){ + if( iRound==0 && zBuf[i+1]>='5' ){ iRound = 1; - p->zBuf[i--] = '0'; - p->n++; + zBuf[i--] = '0'; + n++; p->iDP++; } } - if( iRound>0 && (iRoundn || p->n>mxRound) ){ - char *z = &p->zBuf[i+1]; + if( iRound>0 && (iRoundmxRound) ){ + char *z = &zBuf[i+1]; if( iRound>mxRound ) iRound = mxRound; - p->n = iRound; + n = iRound; if( z[iRound]>='5' ){ int j = iRound-1; while( 1 /*exit-by-break*/ ){ @@ -1257,7 +1259,7 @@ void sqlite3FpDecode(FpDecode *p, double r, int iRound, int mxRound){ z[j] = '0'; if( j==0 ){ p->z[i--] = '1'; - p->n++; + n++; p->iDP++; break; }else{ @@ -1266,13 +1268,15 @@ void sqlite3FpDecode(FpDecode *p, double r, int iRound, int mxRound){ } } } - p->z = &p->zBuf[i+1]; - assert( i+p->n < sizeof(p->zBuf) ); - assert( p->n>0 ); - while( p->z[p->n-1]=='0' ){ - p->n--; - assert( p->n>0 ); + p->z = &zBuf[i+1]; + assert( i+n < sizeof(p->zBuf) ); + assert( n>0 ); + zBuf = p->z; + while( zBuf[n-1]=='0' ){ + n--; + assert( n>0 ); } + p->n = n; } /*