Ignore:
Timestamp:
Oct 24, 2008, 10:22:22 PM (17 years ago)
Author:
bird
Message:

kmk: Made struct variable capable of holding read only variables to speed up set_file_variables.

File:
1 edited

Legend:

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

    r1898 r1932  
    8585      const char *name;
    8686      unsigned int len;
     87#ifdef CONFIG_WITH_STRCACHE2
     88      static const char *suffixes_strcache = 0; /* XXX: make this global */
     89
     90      if (!suffixes_strcache)
     91        suffixes_strcache = strcache_add_len (".SUFFIXES", sizeof (".SUFFIXES") - 1);
     92#endif /* CONFIG_WITH_STRCACHE2 */
    8793
    8894#ifndef NO_ARCHIVES
     
    103109        }
    104110
     111#ifndef CONFIG_WITH_STRCACHE2
    105112      for (d = enter_file (strcache_add (".SUFFIXES"))->deps; d ; d = d->next)
    106113        {
    107 #ifndef CONFIG_WITH_STRCACHE2
    108114          unsigned int slen = strlen (dep_name (d));
    109115#else
     116      for (d = enter_file (suffixes_strcache)->deps; d ; d = d->next)
     117        {
    110118          unsigned int slen = strcache2_get_len (&file_strcache, dep_name (d));
    111119#endif
     
    140148  /* Define the variables.  */
    141149
     150#ifndef CONFIG_WITH_RDONLY_VARIABLE_VALUE
    142151  DEFINE_VARIABLE ("<", 1, less);
    143152  DEFINE_VARIABLE ("*", 1, star);
    144153  DEFINE_VARIABLE ("@", 1, at);
    145154  DEFINE_VARIABLE ("%", 1, percent);
     155#else  /* CONFIG_WITH_RDONLY_VARIABLE_VALUE */
     156# define DEFINE_VARIABLE_RO_VAL(name, len, value, value_len) \
     157  define_variable_in_set((name), (len), (value), (value_len), -1, \
     158        (o_automatic), 0, (file)->variables->set, NILF)
     159
     160  if (*less == '\0')
     161    DEFINE_VARIABLE_RO_VAL ("<", 1, "", 0);
     162  else if (less != at || at == file->name)
     163    DEFINE_VARIABLE_RO_VAL ("<", 1, less, strcache_get_len (less));
     164  else
     165    DEFINE_VARIABLE ("<", 1, less);
     166
     167  if (*star == '\0')
     168    DEFINE_VARIABLE_RO_VAL ("*", 1, "", 0);
     169  else
     170    DEFINE_VARIABLE_RO_VAL ("*", 1, star, strcache_get_len (star));
     171
     172  if (at == file->name)
     173    DEFINE_VARIABLE_RO_VAL ("@", 1, at, strcache_get_len (at));
     174  else
     175    DEFINE_VARIABLE ("@", 1, at);
     176
     177  if (*percent == '\0')
     178    DEFINE_VARIABLE_RO_VAL ("%", 1, "", 0);
     179  else
     180    DEFINE_VARIABLE ("%", 1, percent);
     181#endif /* CONFIG_WITH_RDONLY_VARIABLE_VALUE */
    146182
    147183  /* Compute the values for $^, $+, $?, and $|.  */
Note: See TracChangeset for help on using the changeset viewer.