Index: src/java/org/apache/lucene/index/FieldsReader.java =================================================================== --- src/java/org/apache/lucene/index/FieldsReader.java (revision 962932) +++ src/java/org/apache/lucene/index/FieldsReader.java (working copy) @@ -218,8 +218,8 @@ long position = indexStream.readLong(); fieldsStream.seek(position); - Document doc = new Document(); - int numFields = fieldsStream.readVInt(); + final int numFields = fieldsStream.readVInt(); + final Document doc = new Document((fieldSelector == null && numFields > 10) ? numFields : 10); for (int i = 0; i < numFields; i++) { int fieldNumber = fieldsStream.readVInt(); FieldInfo fi = fieldInfos.fieldInfo(fieldNumber); Index: src/java/org/apache/lucene/document/Document.java =================================================================== --- src/java/org/apache/lucene/document/Document.java (revision 962932) +++ src/java/org/apache/lucene/document/Document.java (working copy) @@ -18,6 +18,7 @@ */ import java.util.*; // for javadoc + import org.apache.lucene.search.ScoreDoc; // for javadoc import org.apache.lucene.search.Searcher; // for javadoc import org.apache.lucene.index.IndexReader; // for javadoc @@ -37,13 +38,26 @@ */ public final class Document implements java.io.Serializable { - List fields = new ArrayList(); + final List fields; private float boost = 1.0f; /** Constructs a new document with no fields. */ - public Document() {} + public Document() { + this(new ArrayList()); + } + + /** Construct a Document with an initial capacity for fields + * @param initialCapacity initial number of fields in the internal List */ + public Document(final int initialCapacity) { + this(new ArrayList(initialCapacity)); + } + + /** Construct a Document with a List of Fieldables + * @param fields a List of Fielables to use. NOT COPIED, so be careful */ + public Document(final List fields) { + this.fields = fields; + } - /** Sets a boost factor for hits on any field of this document. This value * will be multiplied into the score of all hits on this document. *