Branch: Tag:

2013-05-25

2013-05-25 17:30:15 by Per Hedbor <ph@opera.com>

The operation "empty_string += string" is now significantly faster.

This is rather common in code that works with buffers. Previously it
was, somewhat surpisingly, significantly faster to write code like:

if( strlen( x ) )
x += str;
else
x = str;

than it was to simply add the str to x regardless of whether or not x
already had contents.

Now the check is done in `+() instead. However, it still does not
handle things like "" + str + "", which might perhaps be useful, but
is significantly less common in real code.

str + "" was already handled.

1571:    pop_n_elems(args-1);    return;    } +  else if(args == 2 && (size == sp[-1].u.string->len)) +  { +  stack_swap(); +  pop_stack(); +  return; +  }       tmp=sp[-args].u.string->len;    r=new_realloc_shared_string(sp[-args].u.string,size,max_shift);