# HG changeset patch # User Sascha L. Teichmann # Date 1308239840 0 # Node ID 3629d36f0e5d3eeb610f5e5510a5301729795ab4 # Parent 756bd8f0b97c97a85202f7a0762eb62c2938ec62 Alloc TreeNode arrays with the right size because its known. flys-client/trunk@2138 c6561f87-3c4e-4783-a992-168aeb5c3f6f diff -r 756bd8f0b97c -r 3629d36f0e5d flys-client/ChangeLog --- a/flys-client/ChangeLog Wed Jun 15 09:03:27 2011 +0000 +++ b/flys-client/ChangeLog Thu Jun 16 15:57:20 2011 +0000 @@ -1,3 +1,8 @@ +2011-06-16 Sascha L. Teichmann + + * src/main/java/de/intevation/flys/client/client/ui/DatacageWindow.java: + Alloc TreeNode array with the right size because its known. + 2011-06-15 Ingo Weinzierl * src/main/java/de/intevation/flys/client/client/ui/DoubleArrayPanel.java: diff -r 756bd8f0b97c -r 3629d36f0e5d flys-client/src/main/java/de/intevation/flys/client/client/ui/DatacageWindow.java --- a/flys-client/src/main/java/de/intevation/flys/client/client/ui/DatacageWindow.java Wed Jun 15 09:03:27 2011 +0000 +++ b/flys-client/src/main/java/de/intevation/flys/client/client/ui/DatacageWindow.java Thu Jun 16 15:57:20 2011 +0000 @@ -101,7 +101,7 @@ } protected void buildTree(DataCageTree tree) { - treeGrid.setData(convert(tree)); + treeGrid.setData(convertTree(tree)); } protected static TreeNode convert(DataCageNode node) { @@ -110,13 +110,11 @@ TreeNode [] cs; if (children != null) { - ArrayList nc = new ArrayList(children.size()); + cs = new TreeNode[children.size()]; - for (DataCageNode dcn: children) { - nc.add(convert(dcn)); + for (int i = 0, N = children.size(); i < N; ++i) { + cs[i] = convert(children.get(i)); } - - cs = nc.toArray(new TreeNode[nc.size()]); } else { cs = new TreeNode[0]; @@ -125,7 +123,7 @@ return new TreeNode(node.getName(), cs); } - protected static Tree convert(DataCageTree tree) { + protected static Tree convertTree(DataCageTree tree) { DataCageNode root = tree.getRoot(); List children = root.getChildren(); @@ -133,14 +131,11 @@ TreeNode [] cs; if (children != null) { - ArrayList nc = new ArrayList(children.size()); + cs = new TreeNode[children.size()]; - if (nc != null) { - for (DataCageNode dcn: children) { - nc.add(convert(dcn)); - } + for (int i = 0, N = children.size(); i < N; ++i) { + cs[i] = convert(children.get(i)); } - cs = nc.toArray(new TreeNode[nc.size()]); } else { cs = new TreeNode[0];