getElement() now uses O(1) get from hash instead of linear O(n) search. Enables us to read large files easily.

This commit is contained in:
Mark DePristo 2011-07-12 08:52:31 -04:00
parent f313e14e4e
commit 8056a3fe89
1 changed files with 6 additions and 4 deletions

View File

@ -107,11 +107,13 @@ public class DiffNode extends DiffValue {
return getElements(false);
}
/**
* Returns the element bound to name, or null if no such binding exists
* @param name
* @return
*/
public DiffElement getElement(String name) {
for ( DiffElement elt : getElements() )
if ( elt.getName().equals(name) )
return elt;
return null;
return getElementMap().get(name);
}
/**