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

Convert an ALWAYS() in sqlite3DbSpanDup() into an assert(), for a performance

increase and size reduction.

FossilOrigin-Name: 21e80a29737c367babcc0cf2533eed61b5d0fcf3cc3c33ab88761899e394eaf3
This commit is contained in:
drh
2022-11-22 12:47:32 +00:00
parent da217c958e
commit c59b7a8053
3 changed files with 13 additions and 8 deletions

View File

@@ -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);
}