Fossil SCM

Merge the versionable-settings cache into trunk.

drh 2011-08-23 14:47 trunk merge
Commit ea51d1272ca5f4ada919ae5491f71cf51092b7a5
1 file changed +24 -3
+24 -3
--- src/db.c
+++ src/db.c
@@ -1407,15 +1407,30 @@
14071407
** .fossil-settings/<name> , and emits warnings if necessary.
14081408
** Returns the non-versioned value without modification if there is no
14091409
** versioned value.
14101410
*/
14111411
static char *db_get_do_versionable(const char *zName, char *zNonVersionedSetting){
1412
- /* Attempt to load the versioned setting from a checked out file */
14131412
char *zVersionedSetting = 0;
14141413
int noWarn = 0;
1415
-
1416
- if( db_open_local() ){
1414
+ struct _cacheEntry {
1415
+ struct _cacheEntry *next;
1416
+ const char *zName, *zValue;
1417
+ } *cacheEntry = 0;
1418
+ static struct _cacheEntry *cache = 0;
1419
+
1420
+ /* Look up name in cache */
1421
+ cacheEntry = cache;
1422
+ while( cacheEntry!=0 ){
1423
+ if( fossil_strcmp(cacheEntry->zName, zName)==0 ){
1424
+ zVersionedSetting = fossil_strdup(cacheEntry->zValue);
1425
+ break;
1426
+ }
1427
+ cacheEntry = cacheEntry->next;
1428
+ }
1429
+ /* Attempt to read value from file in checkout if there wasn't a cache hit
1430
+ ** and a checkout is open. */
1431
+ if( cacheEntry==0 && db_open_local() ){
14171432
Blob versionedPathname;
14181433
char *zVersionedPathname;
14191434
blob_zero(&versionedPathname);
14201435
blob_appendf(&versionedPathname, "%s/.fossil-settings/%s",
14211436
g.zLocalRoot, zName);
@@ -1436,10 +1451,16 @@
14361451
if( file_size(blob_str(&versionedPathname))>=0 ){
14371452
noWarn = 1;
14381453
}
14391454
}
14401455
blob_reset(&versionedPathname);
1456
+ /* Store result in cache, which can be the value or 0 if not found */
1457
+ cacheEntry = (struct _cacheEntry*)fossil_malloc(sizeof(struct _cacheEntry));
1458
+ cacheEntry->next = cache;
1459
+ cacheEntry->zName = zName;
1460
+ cacheEntry->zValue = fossil_strdup(zVersionedSetting);
1461
+ cache = cacheEntry;
14411462
}
14421463
/* Display a warning? */
14431464
if( zVersionedSetting!=0 && zNonVersionedSetting!=0
14441465
&& zNonVersionedSetting[0]!='\0' && !noWarn
14451466
){
14461467
--- src/db.c
+++ src/db.c
@@ -1407,15 +1407,30 @@
1407 ** .fossil-settings/<name> , and emits warnings if necessary.
1408 ** Returns the non-versioned value without modification if there is no
1409 ** versioned value.
1410 */
1411 static char *db_get_do_versionable(const char *zName, char *zNonVersionedSetting){
1412 /* Attempt to load the versioned setting from a checked out file */
1413 char *zVersionedSetting = 0;
1414 int noWarn = 0;
1415
1416 if( db_open_local() ){
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1417 Blob versionedPathname;
1418 char *zVersionedPathname;
1419 blob_zero(&versionedPathname);
1420 blob_appendf(&versionedPathname, "%s/.fossil-settings/%s",
1421 g.zLocalRoot, zName);
@@ -1436,10 +1451,16 @@
1436 if( file_size(blob_str(&versionedPathname))>=0 ){
1437 noWarn = 1;
1438 }
1439 }
1440 blob_reset(&versionedPathname);
 
 
 
 
 
 
1441 }
1442 /* Display a warning? */
1443 if( zVersionedSetting!=0 && zNonVersionedSetting!=0
1444 && zNonVersionedSetting[0]!='\0' && !noWarn
1445 ){
1446
--- src/db.c
+++ src/db.c
@@ -1407,15 +1407,30 @@
1407 ** .fossil-settings/<name> , and emits warnings if necessary.
1408 ** Returns the non-versioned value without modification if there is no
1409 ** versioned value.
1410 */
1411 static char *db_get_do_versionable(const char *zName, char *zNonVersionedSetting){
 
1412 char *zVersionedSetting = 0;
1413 int noWarn = 0;
1414 struct _cacheEntry {
1415 struct _cacheEntry *next;
1416 const char *zName, *zValue;
1417 } *cacheEntry = 0;
1418 static struct _cacheEntry *cache = 0;
1419
1420 /* Look up name in cache */
1421 cacheEntry = cache;
1422 while( cacheEntry!=0 ){
1423 if( fossil_strcmp(cacheEntry->zName, zName)==0 ){
1424 zVersionedSetting = fossil_strdup(cacheEntry->zValue);
1425 break;
1426 }
1427 cacheEntry = cacheEntry->next;
1428 }
1429 /* Attempt to read value from file in checkout if there wasn't a cache hit
1430 ** and a checkout is open. */
1431 if( cacheEntry==0 && db_open_local() ){
1432 Blob versionedPathname;
1433 char *zVersionedPathname;
1434 blob_zero(&versionedPathname);
1435 blob_appendf(&versionedPathname, "%s/.fossil-settings/%s",
1436 g.zLocalRoot, zName);
@@ -1436,10 +1451,16 @@
1451 if( file_size(blob_str(&versionedPathname))>=0 ){
1452 noWarn = 1;
1453 }
1454 }
1455 blob_reset(&versionedPathname);
1456 /* Store result in cache, which can be the value or 0 if not found */
1457 cacheEntry = (struct _cacheEntry*)fossil_malloc(sizeof(struct _cacheEntry));
1458 cacheEntry->next = cache;
1459 cacheEntry->zName = zName;
1460 cacheEntry->zValue = fossil_strdup(zVersionedSetting);
1461 cache = cacheEntry;
1462 }
1463 /* Display a warning? */
1464 if( zVersionedSetting!=0 && zNonVersionedSetting!=0
1465 && zNonVersionedSetting[0]!='\0' && !noWarn
1466 ){
1467

Keyboard Shortcuts

Open search /
Next entry (timeline) j
Previous entry (timeline) k
Open focused entry Enter
Show this help ?
Toggle theme Top nav button