From 3073d0f4d1d158d46578a1a07ba2a739fbdfd2a8 Mon Sep 17 00:00:00 2001
From: Andrea Canciani <ranma42@gmail.com>
Date: Tue, 2 Nov 2010 09:38:51 +0100
Subject: [PATCH 2/3] Remove cursor from TextPool

It is supposed to make the searching faster, but it only works when
the words are already sorted. A more general approach is needed to get
acceptable performance on generic documents.
---
 poppler/TextOutputDev.cc |   14 ++------------
 poppler/TextOutputDev.h  |    2 --
 2 files changed, 2 insertions(+), 14 deletions(-)

diff --git a/poppler/TextOutputDev.cc b/poppler/TextOutputDev.cc
index 576bcc9..b6b92bc 100644
--- a/poppler/TextOutputDev.cc
+++ b/poppler/TextOutputDev.cc
@@ -512,8 +512,6 @@ TextPool::TextPool() {
   minBaseIdx = 0;
   maxBaseIdx = -1;
   pool = NULL;
-  cursor = NULL;
-  cursorBaseIdx = -1;
 }
 
 TextPool::~TextPool() {
@@ -580,14 +578,8 @@ void TextPool::addWord(TextWord *word) {
   }
 
   // insert the new word
-  if (cursor && wordBaseIdx == cursorBaseIdx &&
-      word->primaryCmp(cursor) > 0) {
-    w0 = cursor;
-    w1 = cursor->next;
-  } else {
-    w0 = NULL;
-    w1 = pool[wordBaseIdx - minBaseIdx];
-  }
+  w0 = NULL;
+  w1 = pool[wordBaseIdx - minBaseIdx];
   for (; w1 && word->primaryCmp(w1) > 0; w0 = w1, w1 = w1->next) ;
   word->next = w1;
   if (w0) {
@@ -595,8 +587,6 @@ void TextPool::addWord(TextWord *word) {
   } else {
     pool[wordBaseIdx - minBaseIdx] = word;
   }
-  cursor = word;
-  cursorBaseIdx = wordBaseIdx;
 }
 
 //------------------------------------------------------------------------
diff --git a/poppler/TextOutputDev.h b/poppler/TextOutputDev.h
index 438aee4..47b134b 100644
--- a/poppler/TextOutputDev.h
+++ b/poppler/TextOutputDev.h
@@ -230,8 +230,6 @@ private:
   int maxBaseIdx;		// max baseline bucket index
   TextWord **pool;		// array of linked lists, one for each
 				//   baseline value (multiple of 4 pts)
-  TextWord *cursor;		// pointer to last-accessed word
-  int cursorBaseIdx;		// baseline bucket index of last-accessed word
 
   friend class TextBlock;
   friend class TextPage;
-- 
1.7.0.4

