diff options
author | nyamatongwe <unknown> | 2001-04-25 01:20:44 +0000 |
---|---|---|
committer | nyamatongwe <unknown> | 2001-04-25 01:20:44 +0000 |
commit | c1dade69f80688926f9e038f48ce0b1e711b2ad0 (patch) | |
tree | dc78f7083d7dbaac0309812a68bbd7a2bffd4cb0 /src/CellBuffer.cxx | |
parent | e49295b4ad7940514b53b6bb260df4331fb30375 (diff) | |
download | scintilla-mirror-c1dade69f80688926f9e038f48ce0b1e711b2ad0.tar.gz |
Changed buffer growth strategy to be proportional to current size by doubling
gowth size whenever the buffer size is more than 4 times the buffer size.
Reduced load of 10 Meg file from 12 to 4 seconds and 30 Meg file from 1000
to 21 seconds.
Reformatting.
Diffstat (limited to 'src/CellBuffer.cxx')
-rw-r--r-- | src/CellBuffer.cxx | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/src/CellBuffer.cxx b/src/CellBuffer.cxx index 3e9f0e7b7..56dd27ea0 100644 --- a/src/CellBuffer.cxx +++ b/src/CellBuffer.cxx @@ -597,6 +597,7 @@ CellBuffer::CellBuffer(int initialLength) { part2body = body + gaplen; readOnly = false; collectingUndo = true; + growSize = 4000; } CellBuffer::~CellBuffer() { @@ -627,7 +628,9 @@ void CellBuffer::RoomFor(int insertionLength) { if (gaplen <= insertionLength) { //Platform::DebugPrintf("need room %d %d\n", gaplen, insertionLength); GapTo(length); - int newSize = size + insertionLength + 4000; + if (growSize * 4 < size) + growSize *= 2; + int newSize = size + insertionLength + growSize; //Platform::DebugPrintf("moved gap %d\n", newSize); char *newBody = new char[newSize]; memcpy(newBody, body, size); |