Less GetText reallocs
[SXSI/TextCollection.git] / CSA.cpp
diff --git a/CSA.cpp b/CSA.cpp
index a86407d..0c755f0 100644 (file)
--- a/CSA.cpp
+++ b/CSA.cpp
@@ -290,8 +290,10 @@ uchar* CSA::GetText(DocId k) const
     k -= textRank; //emptyTextRank->rank(k);
     
     TextPosition i = k;
-    // FIXME
-    string result; //TextPosition j = (*textLength)[k] - 1;
+
+    string result;
+    // Reserve average string length to avoid reallocs
+    result.reserve(n/numberOfTexts);
 
     uchar c = alphabetrank->access(i);
     while (c != '\0')