From 63294f1f7bc2274753642305e85b416555d3400a Mon Sep 17 00:00:00 2001 From: Matthew Jason Benson Date: Tue, 21 Nov 2006 19:50:08 +0000 Subject: [PATCH] use a single empty iterator instead of multiple instances... it's all the same groove, my man... git-svn-id: https://svn.apache.org/repos/asf/ant/core/trunk@477846 13f79535-47bb-0310-9956-ffa450edef68 --- .../tools/ant/types/resources/Resources.java | 24 ++++++++++--------- 1 file changed, 13 insertions(+), 11 deletions(-) diff --git a/src/main/org/apache/tools/ant/types/resources/Resources.java b/src/main/org/apache/tools/ant/types/resources/Resources.java index aae28aa5a..84b6fa261 100644 --- a/src/main/org/apache/tools/ant/types/resources/Resources.java +++ b/src/main/org/apache/tools/ant/types/resources/Resources.java @@ -45,23 +45,25 @@ public class Resources extends DataType implements ResourceCollection { return true; } public Iterator iterator() { - return new Iterator() { - public Object next() { - throw new NoSuchElementException(); - } - public boolean hasNext() { - return false; - } - public void remove() { - throw new UnsupportedOperationException(); - } - }; + return EMPTY_ITERATOR; } public int size() { return 0; } }; + private static final Iterator EMPTY_ITERATOR = new Iterator() { + public Object next() { + throw new NoSuchElementException(); + } + public boolean hasNext() { + return false; + } + public void remove() { + throw new UnsupportedOperationException(); + } + }; + private class MyCollection extends AbstractCollection { private int size;