Fossil SCM
Avoid a possibly unnecessary call to db_prepare() when doing a config sync.
Commit
d57a63254c1d4177528b211ec35e38bf115d40e74cbe7deb4c3ee58b9ca6d1e8
Parent
8677e3ca50aed53…
1 file changed
+10
-3
+10
-3
| --- src/configure.c | ||
| +++ src/configure.c | ||
| @@ -513,10 +513,11 @@ | ||
| 513 | 513 | ){ |
| 514 | 514 | Stmt q; |
| 515 | 515 | Blob rec; |
| 516 | 516 | int ii; |
| 517 | 517 | int nCard = 0; |
| 518 | + int bPrepped; | |
| 518 | 519 | |
| 519 | 520 | blob_zero(&rec); |
| 520 | 521 | if( groupMask & CONFIGSET_SHUN ){ |
| 521 | 522 | db_prepare(&q, "SELECT mtime, quote(uuid), quote(scom) FROM shun" |
| 522 | 523 | " WHERE mtime>=%lld", iStart); |
| @@ -647,14 +648,18 @@ | ||
| 647 | 648 | nCard++; |
| 648 | 649 | blob_reset(&rec); |
| 649 | 650 | } |
| 650 | 651 | db_finalize(&q); |
| 651 | 652 | } |
| 652 | - db_prepare(&q, "SELECT mtime, quote(name), quote(value) FROM config" | |
| 653 | - " WHERE name=:name AND mtime>=%lld", iStart); | |
| 653 | + bPrepped = 0; | |
| 654 | 654 | for(ii=0; ii<count(aConfig); ii++){ |
| 655 | 655 | if( (aConfig[ii].groupMask & groupMask)!=0 && aConfig[ii].zName[0]!='@' ){ |
| 656 | + if( !bPrepped ){ | |
| 657 | + db_prepare(&q, "SELECT mtime, quote(name), quote(value) FROM config" | |
| 658 | + " WHERE name=:name AND mtime>=%lld", iStart); | |
| 659 | + bPrepped = 1; | |
| 660 | + } | |
| 656 | 661 | db_bind_text(&q, ":name", aConfig[ii].zName); |
| 657 | 662 | while( db_step(&q)==SQLITE_ROW ){ |
| 658 | 663 | blob_appendf(&rec,"%s %s value %s", |
| 659 | 664 | db_column_text(&q, 0), |
| 660 | 665 | db_column_text(&q, 1), |
| @@ -666,11 +671,13 @@ | ||
| 666 | 671 | blob_reset(&rec); |
| 667 | 672 | } |
| 668 | 673 | db_reset(&q); |
| 669 | 674 | } |
| 670 | 675 | } |
| 671 | - db_finalize(&q); | |
| 676 | + if( bPrepped ){ | |
| 677 | + db_finalize(&q); | |
| 678 | + } | |
| 672 | 679 | return nCard; |
| 673 | 680 | } |
| 674 | 681 | |
| 675 | 682 | /* |
| 676 | 683 | ** Identify a configuration group by name. Return its mask. |
| 677 | 684 |
| --- src/configure.c | |
| +++ src/configure.c | |
| @@ -513,10 +513,11 @@ | |
| 513 | ){ |
| 514 | Stmt q; |
| 515 | Blob rec; |
| 516 | int ii; |
| 517 | int nCard = 0; |
| 518 | |
| 519 | blob_zero(&rec); |
| 520 | if( groupMask & CONFIGSET_SHUN ){ |
| 521 | db_prepare(&q, "SELECT mtime, quote(uuid), quote(scom) FROM shun" |
| 522 | " WHERE mtime>=%lld", iStart); |
| @@ -647,14 +648,18 @@ | |
| 647 | nCard++; |
| 648 | blob_reset(&rec); |
| 649 | } |
| 650 | db_finalize(&q); |
| 651 | } |
| 652 | db_prepare(&q, "SELECT mtime, quote(name), quote(value) FROM config" |
| 653 | " WHERE name=:name AND mtime>=%lld", iStart); |
| 654 | for(ii=0; ii<count(aConfig); ii++){ |
| 655 | if( (aConfig[ii].groupMask & groupMask)!=0 && aConfig[ii].zName[0]!='@' ){ |
| 656 | db_bind_text(&q, ":name", aConfig[ii].zName); |
| 657 | while( db_step(&q)==SQLITE_ROW ){ |
| 658 | blob_appendf(&rec,"%s %s value %s", |
| 659 | db_column_text(&q, 0), |
| 660 | db_column_text(&q, 1), |
| @@ -666,11 +671,13 @@ | |
| 666 | blob_reset(&rec); |
| 667 | } |
| 668 | db_reset(&q); |
| 669 | } |
| 670 | } |
| 671 | db_finalize(&q); |
| 672 | return nCard; |
| 673 | } |
| 674 | |
| 675 | /* |
| 676 | ** Identify a configuration group by name. Return its mask. |
| 677 |
| --- src/configure.c | |
| +++ src/configure.c | |
| @@ -513,10 +513,11 @@ | |
| 513 | ){ |
| 514 | Stmt q; |
| 515 | Blob rec; |
| 516 | int ii; |
| 517 | int nCard = 0; |
| 518 | int bPrepped; |
| 519 | |
| 520 | blob_zero(&rec); |
| 521 | if( groupMask & CONFIGSET_SHUN ){ |
| 522 | db_prepare(&q, "SELECT mtime, quote(uuid), quote(scom) FROM shun" |
| 523 | " WHERE mtime>=%lld", iStart); |
| @@ -647,14 +648,18 @@ | |
| 648 | nCard++; |
| 649 | blob_reset(&rec); |
| 650 | } |
| 651 | db_finalize(&q); |
| 652 | } |
| 653 | bPrepped = 0; |
| 654 | for(ii=0; ii<count(aConfig); ii++){ |
| 655 | if( (aConfig[ii].groupMask & groupMask)!=0 && aConfig[ii].zName[0]!='@' ){ |
| 656 | if( !bPrepped ){ |
| 657 | db_prepare(&q, "SELECT mtime, quote(name), quote(value) FROM config" |
| 658 | " WHERE name=:name AND mtime>=%lld", iStart); |
| 659 | bPrepped = 1; |
| 660 | } |
| 661 | db_bind_text(&q, ":name", aConfig[ii].zName); |
| 662 | while( db_step(&q)==SQLITE_ROW ){ |
| 663 | blob_appendf(&rec,"%s %s value %s", |
| 664 | db_column_text(&q, 0), |
| 665 | db_column_text(&q, 1), |
| @@ -666,11 +671,13 @@ | |
| 671 | blob_reset(&rec); |
| 672 | } |
| 673 | db_reset(&q); |
| 674 | } |
| 675 | } |
| 676 | if( bPrepped ){ |
| 677 | db_finalize(&q); |
| 678 | } |
| 679 | return nCard; |
| 680 | } |
| 681 | |
| 682 | /* |
| 683 | ** Identify a configuration group by name. Return its mask. |
| 684 |