Index: src/java/org/apache/lucene/analysis/BaseCharFilter.java
===================================================================
--- src/java/org/apache/lucene/analysis/BaseCharFilter.java	(revision 920501)
+++ src/java/org/apache/lucene/analysis/BaseCharFilter.java	(working copy)
@@ -17,8 +17,8 @@
 
 package org.apache.lucene.analysis;
 
-import java.util.ArrayList;
-import java.util.List;
+import java.util.SortedMap;
+import java.util.TreeMap;
 
 /**
  * Base utility class for implementing a {@link CharFilter}.
@@ -33,7 +33,7 @@
  */
 public abstract class BaseCharFilter extends CharFilter {
 
-  private List<OffCorrectMap> pcmList;
+  private TreeMap<Integer, Integer> pcmList;
   
   public BaseCharFilter(CharStream in) {
     super(in);
@@ -49,45 +49,21 @@
     if (pcmList == null || pcmList.isEmpty()) {
       return currentOff;
     }
-    for (int i = pcmList.size() - 1; i >= 0; i--) {
-      if (currentOff >=  pcmList.get(i).off) {
-        return currentOff + pcmList.get(i).cumulativeDiff;
-      }
-    }
-    return currentOff;
+    
+    SortedMap<Integer, Integer> head = pcmList.headMap(currentOff + 1);
+
+    return head.isEmpty() ? currentOff : currentOff + head.get(head.lastKey());
   }
   
   protected int getLastCumulativeDiff() {
     return pcmList == null || pcmList.isEmpty() ?
-      0 : pcmList.get(pcmList.size() - 1).cumulativeDiff;
+      0 : pcmList.get(pcmList.lastKey());
   }
 
   protected void addOffCorrectMap(int off, int cumulativeDiff) {
     if (pcmList == null) {
-      pcmList = new ArrayList<OffCorrectMap>();
+      pcmList = new TreeMap<Integer, Integer>();
     }
-    pcmList.add(new OffCorrectMap(off, cumulativeDiff));
+    pcmList.put(off, cumulativeDiff);
   }
-
-  static class OffCorrectMap {
-
-    int off;
-    int cumulativeDiff;
-
-    OffCorrectMap(int off, int cumulativeDiff) {
-      this.off = off;
-      this.cumulativeDiff = cumulativeDiff;
-    }
-
-    @Override
-    public String toString() {
-      StringBuilder sb = new StringBuilder();
-      sb.append('(');
-      sb.append(off);
-      sb.append(',');
-      sb.append(cumulativeDiff);
-      sb.append(')');
-      return sb.toString();
-    }
-  }
 }
