Mercurial > dive4elements > river
changeset 574:3629d36f0e5d
Alloc TreeNode arrays with the right size because its known.
flys-client/trunk@2138 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author | Sascha L. Teichmann <sascha.teichmann@intevation.de> |
---|---|
date | Thu, 16 Jun 2011 15:57:20 +0000 |
parents | 756bd8f0b97c |
children | 5277f46a63c2 |
files | flys-client/ChangeLog flys-client/src/main/java/de/intevation/flys/client/client/ui/DatacageWindow.java |
diffstat | 2 files changed, 13 insertions(+), 13 deletions(-) [+] |
line wrap: on
line diff
--- 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 <sascha.teichmann@intevation.de> + + * 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 <ingo@intevation.de> * src/main/java/de/intevation/flys/client/client/ui/DoubleArrayPanel.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<TreeNode> nc = new ArrayList<TreeNode>(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<DataCageNode> children = root.getChildren(); @@ -133,14 +131,11 @@ TreeNode [] cs; if (children != null) { - ArrayList<TreeNode> nc = new ArrayList<TreeNode>(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];