pike.git / src / stralloc.c

version» Context lines:

pike.git/src/stralloc.c:19:      #include <errno.h>   #include <float.h>   #include <ctype.h>   #include <math.h>      #ifndef HUGE   #define HUGE HUGE_VAL   #endif /*!HUGE*/    - RCSID("$Id: stralloc.c,v 1.110 2000/12/01 17:43:28 grubba Exp $"); + RCSID("$Id: stralloc.c,v 1.111 2000/12/01 20:36:41 grubba Exp $");      #define BEGIN_HASH_SIZE 997   #define MAX_AVG_LINK_LENGTH 3      /* Experimental dynamic hash length */   #ifndef HASH_PREFIX   static unsigned int HASH_PREFIX=64;   static unsigned int need_more_hash_prefix=0;   #endif   
pike.git/src/stralloc.c:41:   static unsigned int hashprimes_entry=0;   static struct pike_string **base_table=0;   static size_t full_hash_value;   unsigned INT32 num_strings=0;      /*** Main string hash function ***/         #define StrHash(s,len) low_do_hash(s,len,0)    - static size_t low_do_hash(const void *s, ptrdiff_t len, int size_shift) + static INLINE size_t low_do_hash(const void *s, ptrdiff_t len__, +  int size_shift)   { -  full_hash_value=hashmem(s,len<<size_shift,HASH_PREFIX<<size_shift); +  DO_HASHMEM(full_hash_value, s, len__<<size_shift, HASH_PREFIX<<size_shift);    return full_hash_value % htable_size;   }      static INLINE size_t do_hash(struct pike_string *s)   {    return low_do_hash(s->str, s->len, s->size_shift);   }         static INLINE int find_magnitude1(const unsigned INT16 *s, ptrdiff_t len)
pike.git/src/stralloc.c:283:   {    return index_shared_string(s,s->len);   }   #else   #define locate_problem(X)   #endif      /* Find a string in the shared string table.    * This assumes that the string is minimized!!!!    */ - static struct pike_string *internal_findstring(const char *s, + static INLINE struct pike_string *internal_findstring(const char *s,    ptrdiff_t len,    int size_shift,    ptrdiff_t h)   {    struct pike_string *curr,**prev, **base;   #ifndef HASH_PREFIX    unsigned int depth=0;   #endif       for(base = prev = base_table + h;( curr=*prev ); prev=&curr->next)
pike.git/src/stralloc.c:405:    base_table=(struct pike_string **)xalloc(sizeof(struct pike_string *)*htable_size);    MEMSET((char *)base_table,0,sizeof(struct pike_string *)*htable_size);       for(h=0;h<old;h++)    rehash_string_backwards(old_base[h]);       if(old_base)    free((char *)old_base);   }    + /* Allocation of strings */    - /*** Make new strings ***/ + /* Allocate some fixed string sizes with BLOCK_ALLOC. */      /* Use the BLOCK_ALLOC() stuff for short strings */      #define SHORT_STRING_BLOCK 256   #define SHORT_STRING_THRESHOLD 16      struct short_pike_string0 {    struct pike_string str;    p_wchar0 data[SHORT_STRING_THRESHOLD];   };
pike.git/src/stralloc.c:1800:    string_build_mkspace(s, chars, mag);    if(chars<0) s->known_shift=0;    ret = s->s->str + (s->s->len<<s->s->size_shift);    s->s->len += chars;    return ret;   }      PMOD_EXPORT void string_builder_putchar(struct string_builder *s, int ch)   {    ptrdiff_t i; - #if 1 -  if ((min_magnitude(ch) > s->s->size_shift) || -  (((size_t)s->s->len) >= ((size_t)s->malloced))) { -  string_build_mkspace(s,1,min_magnitude(ch)); +  int mag = min_magnitude(ch); +  +  if (mag > s->s->size_shift) { +  string_build_mkspace(s, 1, mag); +  s->known_shift = (size_t)mag; +  } else if (((size_t)s->s->len) >= ((size_t)s->malloced)) { +  string_build_mkspace(s, 1, mag); +  s->known_shift = MAXIMUM((size_t)mag, s->known_shift);    } - #else -  string_build_mkspace(s,1,min_magnitude(ch)); - #endif /* 0 */ -  s->known_shift=MAXIMUM((size_t)min_magnitude(ch),s->known_shift); +     i = s->s->len++;    low_set_index(s->s,i,ch);   }         PMOD_EXPORT void string_builder_binary_strcat(struct string_builder *s, char *str, ptrdiff_t len)   {    string_build_mkspace(s,len,0);    switch(s->s->size_shift)    {