Bug 558398 - Performance leak in AbstractTreeRowModel
Change-Id: Ic95d08a340575798978980e0dfa817033155e05c
Signed-off-by: Dirk Fauth <dirk.fauth@googlemail.com>
diff --git a/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/tree/AbstractTreeRowModel.java b/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/tree/AbstractTreeRowModel.java
index d1f9886..04f49ca 100644
--- a/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/tree/AbstractTreeRowModel.java
+++ b/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/tree/AbstractTreeRowModel.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2012, 2018 Original authors and others.
+ * Copyright (c) 2012, 2019 Original authors and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -12,13 +12,12 @@
package org.eclipse.nebula.widgets.nattable.tree;
import java.util.ArrayList;
-import java.util.Collection;
import java.util.HashSet;
import java.util.List;
public abstract class AbstractTreeRowModel<T> implements ITreeRowModel<T> {
- private final Collection<ITreeRowModelListener> listeners = new HashSet<ITreeRowModelListener>();
+ private final HashSet<ITreeRowModelListener> listeners = new HashSet<>();
private final ITreeData<T> treeData;
@@ -38,7 +37,7 @@
@Override
public int depth(int index) {
- return this.treeData.getDepthOfData(this.treeData.getDataAtIndex(index));
+ return getTreeData().getDepthOfData(index);
}
@Override
@@ -90,7 +89,7 @@
@Override
public List<Integer> getChildIndexes(int parentIndex) {
- List<Integer> result = new ArrayList<Integer>();
+ List<Integer> result = new ArrayList<>();
List<T> children = getDirectChildren(parentIndex);
for (T child : children) {
int index = this.treeData.indexOf(child);
@@ -107,7 +106,7 @@
@Override
public List<Integer> getDirectChildIndexes(int parentIndex) {
List<T> children = getDirectChildren(parentIndex);
- List<Integer> result = new ArrayList<Integer>(children.size());
+ List<Integer> result = new ArrayList<>(children.size());
for (T child : children) {
int index = this.treeData.indexOf(child);
// if the index is -1 the element is not found
@@ -125,7 +124,7 @@
}
protected List<T> getChildren(T parent) {
- List<T> result = new ArrayList<T>();
+ List<T> result = new ArrayList<>();
List<T> children = getDirectChildren(parent);
for (T child : children) {
result.add(child);
diff --git a/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/tree/TreeLayer.java b/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/tree/TreeLayer.java
index 1d14101..0d77e83 100644
--- a/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/tree/TreeLayer.java
+++ b/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/tree/TreeLayer.java
@@ -461,7 +461,7 @@
* underlying layer <code>false</code> if not.
*/
private boolean isHiddenInUnderlyingLayer(int rowIndex) {
- IUniqueIndexLayer underlyingLayer = (IUniqueIndexLayer) getUnderlyingLayer();
+ IUniqueIndexLayer underlyingLayer = getUnderlyingLayer();
return (underlyingLayer.getRowPositionByIndex(rowIndex) == -1);
}