diff options
author | drh <> | 2022-11-22 12:47:32 +0000 |
---|---|---|
committer | drh <> | 2022-11-22 12:47:32 +0000 |
commit | c59b7a8053f0bad8d5df2d834b446a0594ade49c (patch) | |
tree | c61646041a415cd163f3fb0ffbc252c237764c0c /src/malloc.c | |
parent | da217c958eb14824c3bd308a279d9cad19fea35b (diff) | |
download | sqlite-c59b7a8053f0bad8d5df2d834b446a0594ade49c.tar.gz sqlite-c59b7a8053f0bad8d5df2d834b446a0594ade49c.zip |
Convert an ALWAYS() in sqlite3DbSpanDup() into an assert(), for a performance
increase and size reduction.
FossilOrigin-Name: 21e80a29737c367babcc0cf2533eed61b5d0fcf3cc3c33ab88761899e394eaf3
Diffstat (limited to 'src/malloc.c')
-rw-r--r-- | src/malloc.c | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/src/malloc.c b/src/malloc.c index af83743fc..68d9f5f55 100644 --- a/src/malloc.c +++ b/src/malloc.c @@ -793,9 +793,14 @@ char *sqlite3DbStrNDup(sqlite3 *db, const char *z, u64 n){ */ char *sqlite3DbSpanDup(sqlite3 *db, const char *zStart, const char *zEnd){ int n; +#ifdef SQLITE_DEBUG + /* Because of the way the parser works, the span is guaranteed to contain + ** at least one non-space character */ + for(n=0; sqlite3Isspace(zStart[n]); n++){ assert( &zStart[n]<zEnd ); } +#endif while( sqlite3Isspace(zStart[0]) ) zStart++; n = (int)(zEnd - zStart); - while( ALWAYS(n>0) && sqlite3Isspace(zStart[n-1]) ) n--; + while( sqlite3Isspace(zStart[n-1]) ) n--; return sqlite3DbStrNDup(db, zStart, n); } |