From a8436cea2a59cce5dc3b090967e5913c08196586 Mon Sep 17 00:00:00 2001 From: nyamatongwe Date: Wed, 25 Apr 2001 01:20:44 +0000 Subject: 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. --- src/CellBuffer.cxx | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'src/CellBuffer.cxx') 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); -- cgit v1.2.3