Ignore:
Timestamp:
2013-08-03T00:21:50+02:00 (7 years ago)
Author:
Don-vip
Message:

see #8902 - Small performance enhancements / coding style (patch by shinigami):

  • set init size for lists when obvious
Location:
trunk/src/org/openstreetmap/josm/actions
Files:
4 edited

Legend:

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

    r6084 r6106  
    154154                unreversedTagWays.removeAll(reversedWays);
    155155                ReverseWayTagCorrector reverseWayTagCorrector = new ReverseWayTagCorrector();
    156                 List<Way> reversedTagWays = new ArrayList<Way>();
     156                List<Way> reversedTagWays = new ArrayList<Way>(reversedWays.size());
    157157                Collection<Command> changePropertyCommands =  null;
    158158                for (Way w : reversedWays) {
     
    497497
    498498        protected Set<Node> getNodes(Stack<NodePair> pairs) {
    499             HashSet<Node> nodes = new LinkedHashSet<Node>();
     499            HashSet<Node> nodes = new LinkedHashSet<Node>(2*pairs.size());
    500500            for (NodePair pair: pairs) {
    501501                nodes.add(pair.getA());
     
    517517
    518518        protected Set<Node> getNodes() {
    519             Set<Node> nodes = new LinkedHashSet<Node>();
     519            Set<Node> nodes = new LinkedHashSet<Node>(2 * edges.size());
    520520            for (NodePair pair: edges) {
    521521                nodes.add(pair.getA());
  • trunk/src/org/openstreetmap/josm/actions/CreateCircleAction.java

    r6093 r6106  
    137137
    138138            // build a way for the circle
    139             List<Node> wayToAdd = new ArrayList<Node>();
     139            List<Node> wayToAdd = new ArrayList<Node>(numberOfNodesInCircle + 1);
    140140
    141141            for (int i = 1; i <= numberOfNodesInCircle; i++) {
  • trunk/src/org/openstreetmap/josm/actions/PasteTagsAction.java

    r6069 r6106  
    263263    public static boolean pasteTagsFromText(Collection<OsmPrimitive> selection, String text) {
    264264        Map<String, String> tags = TextTagParser.readTagsFromText(text);
    265         List<Command> commands = new ArrayList<Command>();
    266265        if (tags==null || tags.isEmpty()) {
    267266            TextTagParser.showBadBufferMessage(help);
     
    269268        }
    270269        if (!TextTagParser.validateTags(tags)) return false;
     270
     271        List<Command> commands = new ArrayList<Command>(tags.size());
    271272        String v;
    272273        for (String key: tags.keySet()) {
  • trunk/src/org/openstreetmap/josm/actions/search/SearchAction.java

    r6084 r6106  
    103103            searchHistory.removeLast();
    104104        }
    105         List<String> savedHistory = new ArrayList<String>();
     105        List<String> savedHistory = new ArrayList<String>(searchHistory.size());
    106106        for (SearchSetting item: searchHistory) {
    107107            savedHistory.add(item.writeToString());
Note: See TracChangeset for help on using the changeset viewer.