Ignore:
Timestamp:
Oct 10, 2008, 4:27:38 AM (17 years ago)
Author:
bird
Message:

kmk: More length and alloc optimizations. Made all the length optimizations from yesterday CONFIG_WITH_VALUE_LENGTH instead of KMK.

File:
1 edited

Legend:

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

    r1805 r1809  
    931931  char *list = expand_argument (argv[1], NULL);
    932932  const char *body = argv[2];
    933 #ifdef KMK
     933#ifdef CONFIG_WITH_VALUE_LENGTH
    934934  long body_len = strlen (body);
    935 #endif /* KMK - optimization */
     935#endif
    936936
    937937  int doneany = 0;
     
    947947  while ((p = find_next_token (&list_iterator, &len)) != 0)
    948948    {
    949 #ifndef KMK
     949#ifndef CONFIG_WITH_VALUE_LENGTH
    950950      char *result = 0;
    951 #endif /* KMK - optimization */
    952 #ifdef CONFIG_WITH_VALUE_LENGTH
     951
     952      free (var->value);
     953      var->value = savestring (p, len);
     954      result = allocated_variable_expand (body);
     955
     956      o = variable_buffer_output (o, result, strlen (result));
     957      o = variable_buffer_output (o, " ", 1);
     958      doneany = 1;
     959      free (result);
     960#else  /* CONFIG_WITH_VALUE_LENGTH */
    953961      if (len >= (unsigned int)var->value_alloc_len)
    954962        {
     
    960968      var->value[len] = '\0';
    961969      var->value_length = len;
    962 #else
    963       free (var->value);
    964       var->value = savestring (p, len);
    965 #endif
    966 
    967 #ifndef KMK
    968       result = allocated_variable_expand (body);
    969 
    970       o = variable_buffer_output (o, result, strlen (result));
    971       o = variable_buffer_output (o, " ", 1);
    972       doneany = 1;
    973       free (result);
    974 #else  /* KMK - optimization */
     970
    975971      variable_expand_string_2 (o, body, body_len, &o);
    976972      o = variable_buffer_output (o, " ", 1);
    977973      doneany = 1;
    978 #endif /* KMK - optimization */
     974#endif /* CONFIG_WITH_VALUE_LENGTH */
    979975    }
    980976
     
    43144310
    43154311      v->exp_count = EXP_COUNT_MAX;
    4316 #ifndef KMK
     4312#ifndef CONFIG_WITH_VALUE_LENGTH
    43174313      o = variable_expand_string (o, body, flen+3);
    43184314      v->exp_count = 0;
    43194315
    43204316      o += strlen (o);
    4321 #else  /* KMK - optimization */
     4317#else  /* CONFIG_WITH_VALUE_LENGTH */
    43224318      variable_expand_string_2 (o, body, flen+3, &o);
    43234319      v->exp_count = 0;
    4324 #endif /* KMK - optimization */
     4320#endif /* CONFIG_WITH_VALUE_LENGTH */
    43254321#ifdef CONFIG_WITH_EVALPLUS
    43264322    }
Note: See TracChangeset for help on using the changeset viewer.