aboutsummaryrefslogtreecommitdiffhomepage
path: root/src
diff options
context:
space:
mode:
authornyamatongwe <devnull@localhost>2002-08-03 02:52:17 +0000
committernyamatongwe <devnull@localhost>2002-08-03 02:52:17 +0000
commit734741819ffb01a79faa13abe15462acb9054f37 (patch)
treec53587cb73821b59d817fa3dda4f5cebfb2430f0 /src
parent4ed5d9ed82301348ce447a53768523cfcf0ab01a (diff)
downloadscintilla-mirror-734741819ffb01a79faa13abe15462acb9054f37.tar.gz
Changed LineVector to use an exponential allocation strategy which
minimises the memory allocated for short files but avoids excessive copying for huge files. 23 Meg file load changes from 17 seconds to 3.
Diffstat (limited to 'src')
-rw-r--r--src/CellBuffer.cxx3
-rw-r--r--src/CellBuffer.h2
2 files changed, 4 insertions, 1 deletions
diff --git a/src/CellBuffer.cxx b/src/CellBuffer.cxx
index b67da81c9..420dee6ff 100644
--- a/src/CellBuffer.cxx
+++ b/src/CellBuffer.cxx
@@ -125,6 +125,7 @@ LineVector::LineVector() {
levels = 0;
sizeLevels = 0;
handleCurrent = 1;
+ growSize = 1000;
Init();
}
@@ -199,6 +200,8 @@ void LineVector::ClearLevels() {
void LineVector::InsertValue(int pos, int value) {
//Platform::DebugPrintf("InsertValue[%d] = %d\n", pos, value);
if ((lines + 2) >= size) {
+ if (growSize * 6 < size)
+ growSize *= 2;
Expand(size + growSize);
if (levels) {
ExpandLevels(size + growSize);
diff --git a/src/CellBuffer.h b/src/CellBuffer.h
index b5c90f57a..5cfcbfe1f 100644
--- a/src/CellBuffer.h
+++ b/src/CellBuffer.h
@@ -53,7 +53,7 @@ struct LineData {
*/
class LineVector {
public:
- enum { growSize = 4000 };
+ int growSize;
int lines;
LineData *linesData;
int size;