VirtualBox

Changeset 1800 in kBuild for trunk/src/kmk


Ignore:
Timestamp:
Sep 21, 2008 1:43:59 AM (16 years ago)
Author:
bird
Message:

incdep: weeny strcache_add_len optimization.

File:
1 edited

Legend:

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

    r1799 r1800  
    499499
    500500  incdep_initialized = 0;
     501}
     502
     503/* A quick wrapper around strcache_add_len which avoid the unnecessary
     504   copying of the string in order to terminate it. The incdep buffer is
     505   always writable, but the eval function like to use const char to avoid
     506   silly mistakes and encourage compiler optimizations. */
     507static char *
     508incdep_strcache_add_len (const char *str, int len)
     509{
     510#if 1
     511  char *ret;
     512  char ch = str[len];
     513  ((char *)str)[len] = '\0';
     514  ret = strcache_add_len (str, len);
     515  ((char *)str)[len] = ch;
     516  return ret;
     517#else
     518  return strcache_add_len (str, len);
     519#endif
    501520}
    502521
     
    597616              break;
    598617          }
    599           var = strcache_add_len (cur, var_len);
     618          var = incdep_strcache_add_len (cur, var_len);
    600619
    601620          /* find the end of the variable. */
     
    759778                  break;
    760779                }
    761               var = strcache_add_len (cur, var_len);
     780              var = incdep_strcache_add_len (cur, var_len);
    762781
    763782              /* find the start of the value. */
     
    882901              filenames = xmalloc (sizeof (struct nameseq));
    883902              memset (filenames, 0, sizeof (*filenames));
    884               filenames->name = strcache_add_len (cur, endp - cur);
     903              filenames->name = incdep_strcache_add_len (cur, endp - cur);
    885904
    886905              /* parse any dependencies. */
     
    921940                  /* add it to the list. */
    922941                  *nextdep = dep = alloc_dep ();
    923                   dep->name = strcache_add_len (cur, endp - cur);
     942                  dep->name = incdep_strcache_add_len (cur, endp - cur);
    924943                  nextdep = &dep->next;
    925944
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