Ignore:
Timestamp:
Sep 16, 2006, 4:37:51 PM (19 years ago)
Author:
bird
Message:

tuning. libc is 1-2 seconds faster to load now.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/gmake/function.c

    r520 r526  
    3232# include "pathstuff.h"
    3333#endif
     34#include <assert.h> /* bird */
    3435
    3536
     
    261262
    262263
     264/* The maximum length of a function, once reached there is
     265   it can't be function and we can skip the hash lookup drop out. */
     266
     267#define MAX_FUNCTION_LENGTH 10 /* bird */
     268
    263269/* Look up a function by name.  */
    264 
     270#if defined(__GNUC__) || defined(_MSC_VER)
     271__inline
     272#endif
    265273static const struct function_table_entry *
    266274lookup_function (const char *s)
    267275{
    268276  const char *e = s;
    269 
     277#ifdef MAX_FUNCTION_LENGTH
     278  int left = MAX_FUNCTION_LENGTH;
     279  int ch;
     280  while (((ch = *e) >= 'a' && ch <='z') || ch == '-')
     281    {
     282      if (!left--)
     283        return 0;
     284      e++;
     285    }
     286#else
    270287  while (*e && ( (*e >= 'a' && *e <= 'z') || *e == '-'))
    271288    e++;
     289#endif
    272290  if (*e == '\0' || isblank ((unsigned char) *e))
    273291    {
     
    21982216   *STRINGP past the reference and returning nonzero.  If not, return zero.  */
    21992217
    2200 int
    2201 handle_function (char **op, char **stringp)
    2202 {
    2203   const struct function_table_entry *entry_p;
     2218static int
     2219handle_function2 (const struct function_table_entry *entry_p, char **op, char **stringp) /* bird split it up. */
     2220{
    22042221  char openparen = (*stringp)[0];
    22052222  char closeparen = openparen == '(' ? ')' : '}';
     
    22132230  beg = *stringp + 1;
    22142231
    2215   entry_p = lookup_function (beg);
    2216 
    2217   if (!entry_p)
    2218     return 0;
    2219 
    22202232  /* We found a builtin function.  Find the beginning of its arguments (skip
    22212233     whitespace after the name).  */
     
    22982310
    22992311  return 1;
     2312}
     2313
     2314int
     2315handle_function (char **op, char **stringp) /* bird split it up */
     2316{
     2317  const struct function_table_entry *entry_p = lookup_function (*stringp + 1);
     2318  if (!entry_p)
     2319    return 0;
     2320  return handle_function2 (entry_p, op, stringp);
    23002321}
    23012322
     
    24162437  hash_load (&function_table, function_table_init,
    24172438             FUNCTION_TABLE_ENTRIES, sizeof (struct function_table_entry));
    2418 }
     2439#ifdef MAX_FUNCTION_LENGTH /* bird */
     2440  {
     2441    unsigned i;
     2442    for (i = 0; i < FUNCTION_TABLE_ENTRIES; i++)
     2443        assert(function_table_init[i].len <= MAX_FUNCTION_LENGTH);
     2444  }
     2445#endif
     2446}
Note: See TracChangeset for help on using the changeset viewer.