From: drh <> Date: Mon, 12 Sep 2022 17:44:35 +0000 (+0000) Subject: Faster text decoder for kv_os.c. X-Git-Tag: version-3.40.0~169^2~121^2~3 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=6acd7b0a75206d9dbad55436bb0b48ac53c74413;p=thirdparty%2Fsqlite.git Faster text decoder for kv_os.c. FossilOrigin-Name: 3354a2edb762d70ccc31d4d25f81b70e644d76e01cb1e81d2e97b5414d809d30 --- diff --git a/manifest b/manifest index 601e86a73d..ed3fd61f48 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Fix\suninitialized\svariable\sin\srollback-journal\sprocessing\sin\sos_kv.c -D 2022-09-12T15:59:35.676 +C Faster\stext\sdecoder\sfor\skv_os.c. +D 2022-09-12T17:44:35.983 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724 @@ -574,7 +574,7 @@ F src/notify.c 89a97dc854c3aa62ad5f384ef50c5a4a11d70fcc69f86de3e991573421130ed6 F src/os.c 0eb831ba3575af5277e47f4edd14fdfc90025c67eb25ce5cda634518d308d4e9 F src/os.h 1ff5ae51d339d0e30d8a9d814f4b8f8e448169304d83a7ed9db66a65732f3e63 F src/os_common.h b2f4707a603e36811d9b1a13278bffd757857b85 -F src/os_kv.c 2b4c04a470c05fe95a84d2ba3a5eb4874f0dbaa12da3a47f221ee3beec7eeda0 +F src/os_kv.c 3f4c2f56375d50b210ddadfbfd652001c63e8b8138b8b2c9339e32d610107558 F src/os_setup.h 0711dbc4678f3ac52d7fe736951b6384a0615387c4ba5135a4764e4e31f4b6a6 F src/os_unix.c d6322b78130d995160bb9cfb7850678ad6838b08c1d13915461b33326a406c04 F src/os_win.c e9454cb141908e8eef2102180bad353a36480612d5b736e4c2bd5777d9b25a34 @@ -2004,8 +2004,8 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P 250a935aeb94d3fadec0d3fe22de85de4e658e2fdb3be3aa9a8bbc8f7b7d8414 -R b0d44b8764d44e0d25567b7049186ee6 +P e49682c5eac91958f143e639c5656ca54560d14f5805d514bf4aa0c206e63844 +R 81ed8ce798a46ae2544ed3d032a07983 U drh -Z b805cc7ee3bf0477637e784d78058472 +Z 85de880a922a0287811e4245e97cc473 # Remove this line to create a well-formed Fossil manifest. diff --git a/manifest.uuid b/manifest.uuid index 3839586165..e0ded92cce 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -e49682c5eac91958f143e639c5656ca54560d14f5805d514bf4aa0c206e63844 \ No newline at end of file +3354a2edb762d70ccc31d4d25f81b70e644d76e01cb1e81d2e97b5414d809d30 \ No newline at end of file diff --git a/src/os_kv.c b/src/os_kv.c index 9260852dbe..6ecec6309c 100644 --- a/src/os_kv.c +++ b/src/os_kv.c @@ -527,12 +527,25 @@ static int kvvfsEncode(const char *aData, int nData, char *aOut){ return j; } -/* Convert hex to binary */ -static char kvvfsHexToBinary(char c){ - if( c>='0' && c<='9' ) return c - '0'; - if( c>='A' && c<='F' ) return c - 'A' + 10; - return 0; -} +static const signed char kvvfsHexValue[256] = { + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, -1, -1, -1, -1, -1, -1, + -1, 10, 11, 12, 13, 14, 15, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1 +}; /* ** Decode the text encoding back to binary. The binary content is @@ -540,28 +553,35 @@ static char kvvfsHexToBinary(char c){ ** ** The return value is the number of bytes actually written into aOut[]. */ -static int kvvfsDecode(const char *aIn, char *aOut, int nOut){ +static int kvvfsDecode(const char *a, char *aOut, int nOut){ int i, j; int c; + const unsigned char *aIn = (const unsigned char*)a; i = 0; j = 0; - while( (c = aIn[i])!=0 ){ - if( c>='a' ){ + while( 1 ){ + c = kvvfsHexValue[aIn[i]]; + if( c<0 ){ int n = 0; int mult = 1; + c = aIn[i]; + if( c==0 ) break; while( c>='a' && c<='z' ){ n += (c - 'a')*mult; mult *= 26; c = aIn[++i]; } if( j+n>nOut ) return -1; - while( n-->0 ){ - aOut[j++] = 0; - } + memset(&aOut[j], 0, n); + j += n; + c = aIn[i]; + if( c==0 ) break; }else{ - if( j>nOut ) return -1; - aOut[j] = kvvfsHexToBinary(aIn[i++])<<4; - aOut[j++] += kvvfsHexToBinary(aIn[i++]); + aOut[j] = c<<4; + c = kvvfsHexValue[aIn[++i]]; + if( c<0 ) break; + aOut[j++] += c; + i++; } } return j; @@ -1021,7 +1041,10 @@ static int kvvfsFullPathname( int nOut, char *zOut ){ - size_t nPath = strlen(zPath); + size_t nPath; + +zPath = "local"; + nPath = strlen(zPath); SQLITE_KV_LOG(("xFullPathname(\"%s\")\n", zPath)); if( nOut