: check for null copyField source, delay some allocations

i understanding delaying the allocation of missingFields, but why only a
size of 1 once it is allocated?   (is this just an assumption thta
typically only a few fieldswill be missing?  would it make sense to just
switch to a LinkedLIst since missingFields is only ever used for
iteration?)


: -    List<String> missingFields = new ArrayList<String>( 
schema.getRequiredFields().size() );
: +    List<String> missingFields = null;
:      for (SchemaField field : schema.getRequiredFields()) {
:        if (doc.getField(field.getName() ) == null) {
:          if (field.getDefaultValue() != null) {
:            doc.add( field.createField( field.getDefaultValue(), 1.0f ) );
:          } else {
: +          if (missingFields==null) {
: +            missingFields = new ArrayList<String>(1);
: +          }


-Hoss

Reply via email to