VirtualBox

Changeset 1877 in kBuild for trunk/src/kmk


Ignore:
Timestamp:
Oct 17, 2008 1:29:35 AM (16 years ago)
Author:
bird
Message:

kmk: cache variable name strings.

Location:
trunk/src/kmk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/kmk/variable.c

    r1864 r1877  
    603603  = { 0, &global_variable_set };
    604604struct variable_set_list *current_variable_set_list = &global_setlist;
     605#ifdef CONFIG_WITH_STRCACHE2
     606static struct strcache2 variable_strcache;
     607#endif
    605608
    606609
     
    612615  hash_init (&global_variable_set.table, VARIABLE_BUCKETS,
    613616             variable_hash_1, variable_hash_2, variable_hash_cmp);
     617#ifdef CONFIG_WITH_STRCACHE2
     618  strcache2_init (&variable_strcache, "variable", 65536, 0, 0, 0);
     619#endif
    614620}
    615621
     
    712718  v = alloccache_alloc (&variable_cache);
    713719#endif
     720#ifndef CONFIG_WITH_STRCACHE2
    714721  v->name = savestring (name, length);
     722#else
     723  v->name = strcache2_add (&variable_strcache, name, length);
     724#endif
    715725  v->length = length;
    716726#ifdef VARIABLE_HASH /* bird */
     
    11571167{
    11581168  struct variable *v = (struct variable *) item;
     1169#ifndef CONFIG_WITH_STRCACHE2
    11591170  free (v->name);
     1171#endif
    11601172  free (v->value);
    11611173}
     
    16951707                struct variable *gv;
    16961708
     1709#ifndef CONFIG_WITH_VALUE_LENGTH
    16971710                gv = lookup_variable_in_set (v->name, strlen(v->name),
    16981711                                             &global_variable_set);
     1712#else
     1713                assert ((int)strlen(v->name) == v->length);
     1714                gv = lookup_variable_in_set (v->name, v->length,
     1715                                                     &global_variable_set);
     1716#endif
    16991717                if (gv)
    17001718                  v->export = gv->export;
     
    25162534      printf (_("\n# %u pattern-specific variable values"), rules);
    25172535  }
     2536
     2537#ifdef CONFIG_WITH_STRCACHE2
     2538  strcache2_print_stats (&variable_strcache, "# ");
     2539#endif
    25182540}
    25192541
  • trunk/src/kmk/variable.h

    r1847 r1877  
    5757struct variable
    5858  {
     59#ifndef CONFIG_WITH_STRCACHE2
    5960    char *name;                 /* Variable name.  */
     61#else
     62    const char *name;           /* Variable name.  */
     63#endif
    6064    int length;                 /* strlen (name) */
    6165#ifdef VARIABLE_HASH /* bird */
Note: See TracChangeset for help on using the changeset viewer.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette