Branch: Tag:

2013-05-25

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

Optimized array*str when the array only contains one element.

It now simply returns the array element (if it is a string, that is).

2427:    s=str->str;    end=s+(str->len << str->size_shift);    -  ret=allocate_array(10); +  ret=allocate_array(2);    ret->size=0;       mojt=compile_memsearcher(MKPCHARP_STR(del),
2507:    len=0;    delims = 0;    +  +     for(e=a->size, ae=a->item; e--; ae++)    switch(TYPEOF(*ae))    {
2530:    delims--;    }    +  if( a->size == 1 && TYPEOF(*ITEM(a)) == PIKE_T_STRING ) +  { +  struct pike_string * res = ITEM(a)->u.string; +  res->refs++; +  return res; +  } +     ret=begin_wide_shared_string(len,max_shift);    r=MKPCHARP_STR(ret);    len = del->len;