Changeset 26520


Ignore:
Timestamp:
11/27/12 00:06:10 (8 years ago)
Author:
davidb
Message:

Append string functions changed to a doubling algorithm for reserved capacity. This can lead to some over allocation at times, however it helps avoid the *highly* *undesirable* resource debilitating situation where a large text string is being built up by appending a short bits of text one at a time -- as happens when lucenesource::get_document() is required to retrieve a large section of text from a doc.xml file

File:
1 edited

Legend:

Unmodified
Added
Removed
  • main/trunk/greenstone2/common-src/src/lib/text_t.cpp

    r24882 r26520  
    219219  unsigned char *us = (unsigned char *)s;
    220220  if (text.capacity() < (text.size() + len + 2)) {
    221     text.reserve(text.size() + len + 2);
     221    text.reserve((2*text.size()) + len + 2);
    222222  }
    223223
     
    234234  size_t len = strlen(s);
    235235  if (text.capacity() < (text.size() + len + 2)) {
    236     text.reserve(text.size() + len + 2);
     236    text.reserve((2*text.size()) + len + 2);
    237237  }
    238238 
Note: See TracChangeset for help on using the changeset viewer.