- Timestamp:
- Oct 20, 2008, 1:50:58 AM (17 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/kmk/variable.c
r1889 r1890 223 223 #ifndef CONFIG_WITH_STRCACHE2 224 224 var_key.name = (char *) name; 225 #else226 var_key.name = name = strcache2_add (&variable_strcache, name, length);227 #endif228 225 var_key.length = length; 229 226 var_slot = (struct variable **) hash_find_slot (&set->table, &var_key); … … 233 230 234 231 v = *var_slot; 232 #else /* CONFIG_WITH_STRCACHE2 */ 233 var_key.name = name = strcache2_add (&variable_strcache, name, length); 234 var_key.length = length; 235 if ( set != &global_variable_set 236 || !(v = strcache2_get_user_val (&variable_strcache, var_key.name))) 237 { 238 var_slot = (struct variable **) hash_find_slot (&set->table, &var_key); 239 v = *var_slot; 240 } 241 else 242 assert (!v || (v->name == name && !HASH_VACANT (v))); 243 #endif /* CONFIG_WITH_STRCACHE2 */ 235 244 if (! HASH_VACANT (v)) 236 245 { … … 345 354 } 346 355 356 #ifdef CONFIG_WITH_STRCACHE2 357 /* If it's the global set, remember the variable. */ 358 if (set == &global_variable_set) 359 strcache2_set_user_val (&variable_strcache, v->name, v); 360 #endif 347 361 return v; 348 362 } … … 465 479 var_key.name = (char *) name; 466 480 var_key.length = length; 467 #ifdef CONFIG_WITH_STRCACHE2468 var_key.value = (char *)&var_key; /* hack: name not cached */469 #endif470 481 471 482 for (setlist = current_variable_set_list; … … 589 600 590 601 /* lookup the name in the string case, if it's not there it won't 591 be in any of the sets either. */602 be in any of the sets either. Optimize lookups in the global set. */ 592 603 cached_name = strcache2_lookup(&variable_strcache, name, length); 593 604 if (!cached_name) 594 605 return NULL; 606 607 if (set == &global_variable_set) 608 { 609 struct variable *v; 610 v = strcache2_get_user_val (&variable_strcache, cached_name); 611 assert (!v || v->name == cached_name); 612 return v; 613 } 614 595 615 name = cached_name; 596 616 #endif /* CONFIG_WITH_STRCACHE2 */ … … 598 618 var_key.name = (char *) name; 599 619 var_key.length = length; 600 #ifdef CONFIG_WITH_STRCACHE2601 var_key.value = (char *)&var_key; /* hack: name not cached */602 #endif603 620 604 621 return (struct variable *) hash_find_item ((struct hash_table *) &set->table, &var_key);
Note:
See TracChangeset
for help on using the changeset viewer.