1
0
mirror of https://github.com/sqlite/sqlite.git synced 2025-08-08 14:02:16 +03:00

Faster text decoder for kv_os.c.

FossilOrigin-Name: 3354a2edb762d70ccc31d4d25f81b70e644d76e01cb1e81d2e97b5414d809d30
This commit is contained in:
drh
2022-09-12 17:44:35 +00:00
parent 1ad51ffe21
commit 6acd7b0a75
3 changed files with 46 additions and 23 deletions

View File

@@ -1,5 +1,5 @@
C Fix\suninitialized\svariable\sin\srollback-journal\sprocessing\sin\sos_kv.c C Faster\stext\sdecoder\sfor\skv_os.c.
D 2022-09-12T15:59:35.676 D 2022-09-12T17:44:35.983
F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1
F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea
F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724 F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724
@@ -574,7 +574,7 @@ F src/notify.c 89a97dc854c3aa62ad5f384ef50c5a4a11d70fcc69f86de3e991573421130ed6
F src/os.c 0eb831ba3575af5277e47f4edd14fdfc90025c67eb25ce5cda634518d308d4e9 F src/os.c 0eb831ba3575af5277e47f4edd14fdfc90025c67eb25ce5cda634518d308d4e9
F src/os.h 1ff5ae51d339d0e30d8a9d814f4b8f8e448169304d83a7ed9db66a65732f3e63 F src/os.h 1ff5ae51d339d0e30d8a9d814f4b8f8e448169304d83a7ed9db66a65732f3e63
F src/os_common.h b2f4707a603e36811d9b1a13278bffd757857b85 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_setup.h 0711dbc4678f3ac52d7fe736951b6384a0615387c4ba5135a4764e4e31f4b6a6
F src/os_unix.c d6322b78130d995160bb9cfb7850678ad6838b08c1d13915461b33326a406c04 F src/os_unix.c d6322b78130d995160bb9cfb7850678ad6838b08c1d13915461b33326a406c04
F src/os_win.c e9454cb141908e8eef2102180bad353a36480612d5b736e4c2bd5777d9b25a34 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.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc
F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e
F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0
P 250a935aeb94d3fadec0d3fe22de85de4e658e2fdb3be3aa9a8bbc8f7b7d8414 P e49682c5eac91958f143e639c5656ca54560d14f5805d514bf4aa0c206e63844
R b0d44b8764d44e0d25567b7049186ee6 R 81ed8ce798a46ae2544ed3d032a07983
U drh U drh
Z b805cc7ee3bf0477637e784d78058472 Z 85de880a922a0287811e4245e97cc473
# Remove this line to create a well-formed Fossil manifest. # Remove this line to create a well-formed Fossil manifest.

View File

@@ -1 +1 @@
e49682c5eac91958f143e639c5656ca54560d14f5805d514bf4aa0c206e63844 3354a2edb762d70ccc31d4d25f81b70e644d76e01cb1e81d2e97b5414d809d30

View File

@@ -527,12 +527,25 @@ static int kvvfsEncode(const char *aData, int nData, char *aOut){
return j; return j;
} }
/* Convert hex to binary */ static const signed char kvvfsHexValue[256] = {
static char kvvfsHexToBinary(char c){ -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
if( c>='0' && c<='9' ) return c - '0'; -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
if( c>='A' && c<='F' ) return c - 'A' + 10; -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
return 0; 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 ** 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[]. ** 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 i, j;
int c; int c;
const unsigned char *aIn = (const unsigned char*)a;
i = 0; i = 0;
j = 0; j = 0;
while( (c = aIn[i])!=0 ){ while( 1 ){
if( c>='a' ){ c = kvvfsHexValue[aIn[i]];
if( c<0 ){
int n = 0; int n = 0;
int mult = 1; int mult = 1;
c = aIn[i];
if( c==0 ) break;
while( c>='a' && c<='z' ){ while( c>='a' && c<='z' ){
n += (c - 'a')*mult; n += (c - 'a')*mult;
mult *= 26; mult *= 26;
c = aIn[++i]; c = aIn[++i];
} }
if( j+n>nOut ) return -1; if( j+n>nOut ) return -1;
while( n-->0 ){ memset(&aOut[j], 0, n);
aOut[j++] = 0; j += n;
} c = aIn[i];
if( c==0 ) break;
}else{ }else{
if( j>nOut ) return -1; aOut[j] = c<<4;
aOut[j] = kvvfsHexToBinary(aIn[i++])<<4; c = kvvfsHexValue[aIn[++i]];
aOut[j++] += kvvfsHexToBinary(aIn[i++]); if( c<0 ) break;
aOut[j++] += c;
i++;
} }
} }
return j; return j;
@@ -1021,7 +1041,10 @@ static int kvvfsFullPathname(
int nOut, int nOut,
char *zOut char *zOut
){ ){
size_t nPath = strlen(zPath); size_t nPath;
zPath = "local";
nPath = strlen(zPath);
SQLITE_KV_LOG(("xFullPathname(\"%s\")\n", zPath)); SQLITE_KV_LOG(("xFullPathname(\"%s\")\n", zPath));
if( nOut<nPath+1 ) nPath = nOut - 1; if( nOut<nPath+1 ) nPath = nOut - 1;
memcpy(zOut, zPath, nPath); memcpy(zOut, zPath, nPath);