Branch: Tag:

2000-10-10

2000-10-10 01:20:37 by Fredrik Hübinette (Hubbe) <hubbe@hubbe.net>

explode now uses search expression sharing

Rev: src/array.c:1.90

23:   #include "stuff.h"   #include "bignum.h"    - RCSID("$Id: array.c,v 1.89 2000/09/30 15:58:30 mast Exp $"); + RCSID("$Id: array.c,v 1.90 2000/10/10 01:20:37 hubbe Exp $");      PMOD_EXPORT struct array empty_array=   {
1555:    return a;   }    + typedef char *(* explode_searchfunc)(void *,void *,size_t); +    PMOD_EXPORT struct array *explode(struct pike_string *str,    struct pike_string *del)   {
1577:    ITEM(ret)[e].u.string=string_slice(str,e,1);    }    }else{ -  struct generic_mem_searcher searcher; +  SearchMojt mojt; +  explode_searchfunc f;       s=str->str;    end=s+(str->len << str->size_shift);
1585:    ret=allocate_array(10);    ret->size=0;    -  init_generic_memsearcher(&searcher, -  del->str, +  mojt=compile_memsearcher(MKPCHARP_STR(del),    del->len, -  (char)del->size_shift, +     str->len, -  (char)str->size_shift); +  del);    -  while((tmp=(char *)generic_memory_search(&searcher, -  s, -  (end-s)>>str->size_shift, -  (char)str->size_shift))) +  switch(str->size_shift)    { -  +  case 0: f=(explode_searchfunc)mojt.vtab->func0; break; +  case 1: f=(explode_searchfunc)mojt.vtab->func1; break; +  case 2: f=(explode_searchfunc)mojt.vtab->func2; break; + #ifdef PIKE_DEBUG +  default: fatal("Illegal shift.\n"); + #endif +  } +  +  while((tmp = f(mojt.data, s, (end-s)>> str->size_shift))) +  {    if(ret->size == ret->malloced_size)    {    e=ret->size;
1626:       ITEM(ret)[ret->size].type=T_STRING;    ret->size++; +  mojt.vtab->freeme(mojt.data);    }    ret->type_field=BIT_STRING;    return ret;