Changeset 2790 in josm


Ignore:
Timestamp:
2010-01-09T16:37:29+01:00 (15 years ago)
Author:
jttt
Message:

Fixed #4164 Searching for type:node blocked by system many minutes

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/org/openstreetmap/josm/actions/search/SearchAction.java

    r2777 r2790  
    1212import java.util.Collection;
    1313import java.util.Collections;
     14import java.util.HashSet;
    1415import java.util.LinkedList;
    1516import java.util.List;
     
    201202    }
    202203
    203     public static Integer getSelection(SearchSetting s, Collection<OsmPrimitive> sel, Function f) {
    204         Integer foundMatches = 0;
     204    public static int getSelection(SearchSetting s, Collection<OsmPrimitive> sel, Function f) {
     205        int foundMatches = 0;
    205206        try {
    206207            String searchText = s.text;
     
    211212            /*System.out.println(searchText);*/
    212213            SearchCompiler.Match matcher = SearchCompiler.compile(searchText, s.caseSensitive, s.regexSearch);
    213             foundMatches = 0;
     214
     215            if (s.mode == SearchMode.replace) {
     216                sel.clear();
     217            }
     218
    214219            for (OsmPrimitive osm : Main.main.getCurrentDataSet().allNonDeletedCompletePrimitives()) {
    215220                if (s.mode == SearchMode.replace) {
     
    217222                        sel.add(osm);
    218223                        ++foundMatches;
    219                     } else {
    220                         sel.remove(osm);
    221224                    }
    222225                } else if (s.mode == SearchMode.add && !f.isSomething(osm) && matcher.match(osm)) {
     
    262265
    263266        final DataSet ds = Main.main.getCurrentDataSet();
    264         Collection<OsmPrimitive> sel = ds.getSelected();
     267        Collection<OsmPrimitive> sel = new HashSet<OsmPrimitive>(ds.getSelected());
    265268        int foundMatches = getSelection(s, sel, new Function(){
    266269            public Boolean isSomething(OsmPrimitive o){
Note: See TracChangeset for help on using the changeset viewer.