Overview
SHA1 Hash: | 4c37130fde6b2e84f367343afa2f9ae4ae103c2e |
---|---|
Date: | 2009-08-27 18:33:43 |
User: | drh |
Comment: | Various small performance enhancements. |
Timelines: | ancestors | descendants | both | trunk |
Other Links: | files | ZIP archive | manifest |
Tags And Properties
- branch=trunk inherited from [a28c83647d]
- sym-trunk inherited from [a28c83647d]
Changes
[hide diffs]Modified src/blob.c from [1998856256] to [80cddafe2a].
@@ -79,12 +79,27 @@ /* ** We find that the built-in isspace() function does not work for ** some international character sets. So here is a substitute. */ static int blob_isspace(char c){ - return c==' ' || c=='\n' || c=='\t' || - c=='\r' || c=='\f' || c=='\v'; + return c==' ' || (c<='\r' && c>='\t'); +} + +/* +** COMMAND: test-isspace +*/ +void isspace_cmd(void){ + int i; + for(i=0; i<=255; i++){ + if( i==' ' || i=='\n' || i=='\t' || i=='\v' + || i=='\f' || i=='\r' ){ + assert( blob_isspace((char)i) ); + }else{ + assert( !blob_isspace((char)i) ); + } + } + printf("All 256 characters OK\n"); } /* ** This routine is called if a blob operation fails because we ** have run out of memory.
Modified src/content.c from [ebd984372a] to [79f280c4e2].
@@ -151,16 +151,34 @@ } bag_clear(&pending); } /* +** Get the blob.content value for blob.rid=rid. Return 1 on success or +** 0 on failure. +*/ +static int content_of_blob(int rid, Blob *pBlob){ + static Stmt q; + int rc = 0; + db_static_prepare(&q, "SELECT content FROM blob WHERE rid=:rid AND size>=0"); + db_bind_int(&q, ":rid", rid); + if( db_step(&q)==SQLITE_ROW ){ + db_ephemeral_blob(&q, 0, pBlob); + blob_uncompress(pBlob, pBlob); + rc = 1; + } + db_reset(&q); + return rc; +} + + +/* ** Extract the content for ID rid and put it into the ** uninitialized blob. Return 1 on success. If the record ** is a phantom, zero pBlob and return 0. */ int content_get(int rid, Blob *pBlob){ - Stmt q; Blob src; int srcid; int rc = 0; int i; static Bag inProcess; @@ -183,11 +201,11 @@ blob_zero(&contentCache.a[i].content); contentCache.n--; if( i<contentCache.n ){ contentCache.a[i] = contentCache.a[contentCache.n]; } - CONTENT_TRACE(("%*shit cache: %d\n", + CONTENT_TRACE(("%*scache: %d\n", bag_count(&inProcess), "", rid)) return 1; } } @@ -210,21 +228,17 @@ return 0; } bag_insert(&inProcess, srcid); if( content_get(srcid, &src) ){ - db_prepare(&q, "SELECT content FROM blob WHERE rid=%d AND size>=0", rid); - if( db_step(&q)==SQLITE_ROW ){ - Blob delta; - db_ephemeral_blob(&q, 0, &delta); - blob_uncompress(&delta, &delta); + Blob delta; + if( content_of_blob(rid, &delta) ){ blob_init(pBlob,0,0); blob_delta_apply(&src, &delta, pBlob); blob_reset(&delta); rc = 1; } - db_finalize(&q); /* Save the srcid artifact in the cache */ if( contentCache.n<MX_CACHE_CNT ){ i = contentCache.n++; }else if( ((contentCache.skipCnt++)%EXPELL_INTERVAL)!=0 ){ @@ -254,17 +268,13 @@ } } bag_remove(&inProcess, srcid); }else{ /* No delta required. Read content directly from the database */ - db_prepare(&q, "SELECT content FROM blob WHERE rid=%d AND size>=0", rid); - if( db_step(&q)==SQLITE_ROW ){ - db_ephemeral_blob(&q, 0, pBlob); - blob_uncompress(pBlob, pBlob); + if( content_of_blob(rid, pBlob) ){ rc = 1; } - db_finalize(&q); } if( rc==0 ){ bag_insert(&contentCache.missing, rid); }else{ bag_insert(&contentCache.available, rid);
Modified src/encode.c from [1fff362c9d] to [7772615572].
@@ -423,10 +423,18 @@ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 64, 64, 64, 64, 64, 64, 64, 10, 11, 12, 13, 14, 15, 64, 64, 1, 64, 64, 1, 64, 64, 0, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 10, 11, 12, 13, 14, 15, 64, 64, 1, 64, 64, 1, 64, 64, 0, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, + 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, + 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, + 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, + 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, + 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, + 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, + 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, + 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, }; /* ** Decode a N-character base-16 number into base-256. N must be a ** multiple of 2. The output buffer must be at least N/2 characters @@ -450,14 +458,15 @@ /* ** Return true if the input string contains only valid base-16 digits. ** If any invalid characters appear in the string, return false. */ int validate16(const char *zIn, int nIn){ - int c, i; - for(i=0; i<nIn && (c = zIn[i])!=0; i++){ - if( c & ~0x7f ) return 0; - if( zDecode[c]>63 ) return 0; + int i; + for(i=0; i<nIn; i++, zIn++){ + if( zDecode[zIn[0]&0xff]>63 ){ + return zIn[0]==0; + } } return 1; } /*
Modified src/rebuild.c from [523d3c93a0] to [fd43a695c4].
@@ -206,10 +206,11 @@ char *zTable; bag_init(&bagDone); ttyOutput = doOut; processCnt = 0; + printf("0 (0%%)...\r"); fflush(stdout); db_multi_exec(zSchemaUpdates); for(;;){ zTable = db_text(0, "SELECT name FROM sqlite_master" " WHERE type='table'"