Ignore:
Timestamp:
09.09.2009 19:38:48 (3 years ago)
Author:
Gubaer
Message:

see #3393: loooong delay when using presets with a large osm file

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/org/openstreetmap/josm/gui/tagging/ac/AutoCompletionList.java

    r2048 r2088  
    44import java.util.Collection; 
    55import java.util.Collections; 
     6import java.util.HashMap; 
    67import java.util.List; 
     8import java.util.Map; 
    79 
    810import javax.swing.JTable; 
     
    3335    /** the filter expression */ 
    3436    private String filter = null; 
     37    /** map from value to priority */ 
     38    private Map<String,AutoCompletionListItem> valutToItemMap; 
    3539 
    3640    /** 
     
    4044        list = new ArrayList<AutoCompletionListItem>(); 
    4145        filtered = new ArrayList<AutoCompletionListItem>(); 
     46        valutToItemMap = new HashMap<String, AutoCompletionListItem>(); 
    4247    } 
    4348 
     
    148153 
    149154    protected void appendOrUpdatePriority(AutoCompletionListItem toadd) { 
    150         AutoCompletionListItem item = lookup(toadd.getValue()); 
     155        AutoCompletionListItem item = valutToItemMap.get(toadd.getValue()); 
    151156        if (item == null) { 
    152157            // new item does not exist yet. Add it to the list 
    153158            // 
    154159            list.add(toadd); 
     160            valutToItemMap.put(toadd.getValue(), toadd); 
    155161        } else { 
    156162            // new item already exists. Update priority if necessary 
     
    191197        return false; 
    192198    } 
    193  
    194     /** 
    195      *  
    196      * @param value a specific value 
    197      * @return  the auto completion item for this value; null, if there is no 
    198      *   such auto completion item 
    199      */ 
    200     public AutoCompletionListItem lookup(String value) { 
    201         if (value == null) 
    202             return null; 
    203         for (AutoCompletionListItem item : list) { 
    204             if (item.getValue().equals(value)) 
    205                 return item; 
    206         } 
    207         return null; 
    208     } 
    209  
    210199 
    211200    /** 
Note: See TracChangeset for help on using the changeset viewer.