VirtualBox

Changeset 1446 in kBuild


Ignore:
Timestamp:
Mar 30, 2008 7:56:34 AM (17 years ago)
Author:
bird
Message:

Using the variable buffer for temp storage is (probably) fast, smaller and better.

File:
1 edited

Legend:

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

    r1445 r1446  
    15481548  if (v)
    15491549    {
    1550       char *tmp;
    15511550      char *buf;
    15521551      unsigned int len;
    15531552      int var_ctx;
     1553      size_t off;
     1554
     1555      /* Make a copy of the value to the variable buffer since
     1556         eval_buffer will make changes to its input. */
     1557
     1558      off = o - variable_buffer;
     1559      o = variable_buffer_output (o, v->value, v->value_length + 1);
     1560      o = variable_buffer + off;
    15541561
    15551562      /* Eval the value.  Pop the current variable buffer setting so that the
     
    15611568        push_new_variable_scope ();
    15621569
    1563       tmp = xmalloc (v->value_length + 1);
    1564       memcpy (tmp, v->value, v->value_length + 1);
    1565       eval_buffer (tmp);
    1566       free (tmp);
     1570      eval_buffer (o);
    15671571
    15681572      if (var_ctx)
     
    41884192#ifdef CONFIG_WITH_EVALPLUS
    41894193    }
    4190   else if (!strcmp (funcname, "evalcall"))
    4191     {
    4192       /* Evaluate the variable value directly without expanding it first.  */
    4193       char *tmp;
    4194 
    4195       install_variable_buffer (&buf, &len);
    4196 
    4197       tmp = xmalloc (v->value_length + 1);
    4198       memcpy (tmp, v->value, v->value_length + 1);
    4199       eval_buffer (tmp);
    4200       free (tmp);
    4201 
    4202       restore_variable_buffer (buf, len);
    4203     }
    4204   else /* evalcall2: */
    4205     {
    4206       /* Expand the body first and then evaluate the output. */
    4207 
    4208       v->exp_count = EXP_COUNT_MAX;
    4209       o = variable_expand_string (o, body, flen+3);
    4210       v->exp_count = 0;
     4194  else
     4195    {
     4196      if (!strcmp (funcname, "evalcall"))
     4197        {
     4198          /* Evaluate the variable value without expanding it. We
     4199             need a copy since eval_buffer is destructive.  */
     4200
     4201          size_t off = o - variable_buffer;
     4202          o = variable_buffer_output (o, v->value, v->value_length + 1);
     4203          o = variable_buffer + off;
     4204        }
     4205      else
     4206        {
     4207          /* Expand the body first and then evaluate the output. */
     4208
     4209          v->exp_count = EXP_COUNT_MAX;
     4210          o = variable_expand_string (o, body, flen+3);
     4211          v->exp_count = 0;
     4212        }
    42114213
    42124214      install_variable_buffer (&buf, &len);
Note: See TracChangeset for help on using the changeset viewer.

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