mirror of https://github.com/apache/lucene.git
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:
parent
2317133ca2
commit
c58c87b743
|
@ -46,8 +46,6 @@ public final class Document implements IndexDocument{
|
||||||
|
|
||||||
private final List<Field> fields = new ArrayList<Field>();
|
private final List<Field> fields = new ArrayList<Field>();
|
||||||
|
|
||||||
//private final List<Field> fields
|
|
||||||
|
|
||||||
/** Constructs a new document with no fields. */
|
/** Constructs a new document with no fields. */
|
||||||
public Document() {}
|
public Document() {}
|
||||||
|
|
||||||
|
@ -291,28 +289,24 @@ public final class Document implements IndexDocument{
|
||||||
/** Obtains all indexed fields in document */
|
/** Obtains all indexed fields in document */
|
||||||
@Override
|
@Override
|
||||||
public Iterable<? extends IndexableField> indexableFields() {
|
public Iterable<? extends IndexableField> indexableFields() {
|
||||||
Iterator<Field> it = indexedFieldsIterator();
|
return new Iterable<Field>() {
|
||||||
|
@Override
|
||||||
List<IndexableField> result = new ArrayList<IndexableField>();
|
public Iterator<Field> iterator() {
|
||||||
while(it.hasNext()) {
|
return Document.this.indexedFieldsIterator();
|
||||||
result.add(it.next());
|
}
|
||||||
}
|
};
|
||||||
|
|
||||||
return result;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/** Obtains all stored fields in document. */
|
/** Obtains all stored fields in document. */
|
||||||
@Override
|
@Override
|
||||||
public Iterable<? extends StorableField> storableFields() {
|
public Iterable<? extends StorableField> storableFields() {
|
||||||
Iterator<Field> it = storedFieldsIterator();
|
return new Iterable<Field>() {
|
||||||
|
@Override
|
||||||
List<StorableField> result = new ArrayList<StorableField>();
|
public Iterator<Field> iterator() {
|
||||||
while(it.hasNext()) {
|
return Document.this.storedFieldsIterator();
|
||||||
result.add(it.next());
|
}
|
||||||
}
|
};
|
||||||
|
|
||||||
return result;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private Iterator<Field> storedFieldsIterator() {
|
private Iterator<Field> storedFieldsIterator() {
|
||||||
|
|
Loading…
Reference in New Issue