LUCENE-3312: inline Iterator and don't clone into ArrayList.

git-svn-id: https://svn.apache.org/repos/asf/lucene/dev/branches/lucene3312@1377263 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Uwe Schindler 2012-08-25 11:06:09 +00:00
parent 2317133ca2
commit c58c87b743
1 changed files with 12 additions and 18 deletions

View File

@ -46,8 +46,6 @@ public final class Document implements IndexDocument{
private final List<Field> fields = new ArrayList<Field>();
//private final List<Field> fields
/** Constructs a new document with no fields. */
public Document() {}
@ -291,28 +289,24 @@ public final class Document implements IndexDocument{
/** Obtains all indexed fields in document */
@Override
public Iterable<? extends IndexableField> indexableFields() {
Iterator<Field> it = indexedFieldsIterator();
List<IndexableField> result = new ArrayList<IndexableField>();
while(it.hasNext()) {
result.add(it.next());
return new Iterable<Field>() {
@Override
public Iterator<Field> iterator() {
return Document.this.indexedFieldsIterator();
}
return result;
};
}
/** Obtains all stored fields in document. */
@Override
public Iterable<? extends StorableField> storableFields() {
Iterator<Field> it = storedFieldsIterator();
List<StorableField> result = new ArrayList<StorableField>();
while(it.hasNext()) {
result.add(it.next());
return new Iterable<Field>() {
@Override
public Iterator<Field> iterator() {
return Document.this.storedFieldsIterator();
}
return result;
};
}
private Iterator<Field> storedFieldsIterator() {