|
|
| version 1.82, 2001/05/14 13:18:07 | version 1.83, 2001/05/15 14:31:58 |
|---|---|
| Line 23 | Line 23 |
| #include "pa_table.h" | #include "pa_table.h" |
| #include "pa_threads.h" | #include "pa_threads.h" |
| //#include "pa_sapi.h" | #include "pa_sapi.h" |
| #define STRING_STAT_MAX_PIECES 1000 | |
| int string_stat_pieces[STRING_STAT_MAX_PIECES]; | |
| void log_string_stats(Pool& pool) { | |
| for(int i=0; i<STRING_STAT_MAX_PIECES; i++) | |
| if(int v=string_stat_pieces[i]) | |
| SAPI::log(pool, "%i: %10d", | |
| i, v); | |
| } | |
| // String | |
| String::String(Pool& apool, const char *src, size_t src_size, bool tainted) : | String::String(Pool& apool, const char *src, size_t src_size, bool tainted) : |
| Pooled(apool) { | Pooled(apool),expand_times(0) { |
| string_stat_pieces[0]++; | |
| last_chunk=&head; | last_chunk=&head; |
| head.count=CR_PREALLOCATED_COUNT; | head.count=CR_PREALLOCATED_COUNT; |
| append_here=head.rows; | append_here=head.rows; |
| Line 44 String::String(Pool& apool, const char * | Line 52 String::String(Pool& apool, const char * |
| } | } |
| void String::expand() { | void String::expand() { |
| { | |
| int index=min(++expand_times, STRING_STAT_MAX_PIECES-1); | |
| if(index) | |
| string_stat_pieces[index-1]++; | |
| string_stat_pieces[index]++; | |
| } | |
| size_t new_chunk_count=last_chunk->count+last_chunk->count*CR_GROW_PERCENT/100; | size_t new_chunk_count=last_chunk->count+last_chunk->count*CR_GROW_PERCENT/100; |
| last_chunk=static_cast<Chunk *>( | last_chunk=static_cast<Chunk *>( |
| malloc(sizeof(size_t)+sizeof(Chunk::Row)*new_chunk_count+sizeof(Chunk *))); | malloc(sizeof(size_t)+sizeof(Chunk::Row)*new_chunk_count+sizeof(Chunk *))); |
| Line 55 void String::expand() { | Line 70 void String::expand() { |
| } | } |
| String::String(const String& src) : Pooled(src.pool()) { | String::String(const String& src) : Pooled(src.pool()) { |
| string_stat_pieces[0]++; | |
| head.count=CR_PREALLOCATED_COUNT; | head.count=CR_PREALLOCATED_COUNT; |
| size_t src_used_rows=src.fused_rows; | size_t src_used_rows=src.fused_rows; |
| Line 187 int String::cmp(int& partial, const Stri | Line 203 int String::cmp(int& partial, const Stri |
| Chunk::Row *b_end=src.append_here; | Chunk::Row *b_end=src.append_here; |
| size_t a_countdown=a_chunk->count; | size_t a_countdown=a_chunk->count; |
| size_t b_countdown=b_chunk->count; | size_t b_countdown=b_chunk->count; |
| bool a_break=false; | |
| bool b_break=false; | |
| size_t result; | size_t result; |
| size_t pos=0; | size_t pos=0; |
| while(true) { | |
| a_break=a_row==a_end; | |
| b_break=b_row==b_end; | |
| if(a_break || b_break) | |
| break; | |
| bool a_break=size()==0; | |
| bool b_break=size()==0; | |
| if(!(a_break || b_break)) while(true) { | |
| if(pos+a_row->item.size > this_offset) { | if(pos+a_row->item.size > this_offset) { |
| if(lang!=UL_UNSPECIFIED && a_row->item.lang!=lang) | if(lang!=UL_UNSPECIFIED && a_row->item.lang!=lang) |
| return -1; // wrong lang -- bail out | return -1; // wrong lang -- bail out |
| Line 229 int String::cmp(int& partial, const Stri | Line 241 int String::cmp(int& partial, const Stri |
| pos+=a_row->item.size; | pos+=a_row->item.size; |
| a_row++; a_countdown--; a_offset=0; | a_row++; a_countdown--; a_offset=0; |
| } | } |
| if(b_break=b_row==b_end) { | |
| a_break=a_row==a_end; | |
| break; | |
| } | |
| if(!b_countdown) { | if(!b_countdown) { |
| b_chunk=b_row->link; | b_chunk=b_row->link; |
| b_row=b_chunk->rows; | b_row=b_chunk->rows; |
| Line 241 int String::cmp(int& partial, const Stri | Line 256 int String::cmp(int& partial, const Stri |
| a_row++; a_countdown--; | a_row++; a_countdown--; |
| } | } |
| if(a_break=a_row==a_end) { | |
| b_break=b_row==b_end; | |
| break; | |
| } | |
| if(!a_countdown) { | if(!a_countdown) { |
| a_chunk=a_row->link; | a_chunk=a_row->link; |
| a_row=a_chunk->rows; | a_row=a_chunk->rows; |
| Line 269 int String::cmp(int& partial, const char | Line 288 int String::cmp(int& partial, const char |
| size_t b_offset=0; | size_t b_offset=0; |
| Chunk::Row *a_end=append_here; | Chunk::Row *a_end=append_here; |
| size_t a_countdown=a_chunk->count; | size_t a_countdown=a_chunk->count; |
| bool a_break=false; | |
| bool b_break=false; | |
| size_t pos=0; | size_t pos=0; |
| while(true) { | |
| a_break=a_row==a_end; | |
| if(a_break || b_break) | |
| break; | |
| bool a_break=size()==0; | |
| bool b_break=b_size==0; | |
| if(!(a_break || b_break)) while(true) { | |
| if(pos+a_row->item.size > this_offset) { | if(pos+a_row->item.size > this_offset) { |
| if(lang!=UL_UNSPECIFIED && a_row->item.lang!=lang) | if(lang!=UL_UNSPECIFIED && a_row->item.lang!=lang) |
| return -1; // wrong lang -- bail out | return -1; // wrong lang -- bail out |
| Line 312 int String::cmp(int& partial, const char | Line 328 int String::cmp(int& partial, const char |
| a_row++; a_countdown--; | a_row++; a_countdown--; |
| } | } |
| if(a_break=a_row==a_end) | |
| break; | |
| if(!a_countdown) { | if(!a_countdown) { |
| a_chunk=a_row->link; | a_chunk=a_row->link; |
| a_row=a_chunk->rows; | a_row=a_chunk->rows; |