Merge pull request #7497 from twilson-palantir/master

Specify capacity for internal ArrayLists whose size is known
This commit is contained in:
Lukas Eder 2018-05-23 12:50:54 +02:00 committed by GitHub
commit 3146a29a19
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
34 changed files with 113 additions and 110 deletions

View File

@ -231,9 +231,10 @@ public abstract class AbstractGeneratorStrategy implements GeneratorStrategy {
@Override
public final List<String> getJavaIdentifiers(Collection<? extends Definition> definitions) {
List<String> result = new ArrayList<String>();
List<? extends Definition> nonNull = nonNull(definitions);
List<String> result = new ArrayList<String>(nonNull.size());
for (Definition definition : nonNull(definitions)) {
for (Definition definition : nonNull) {
result.add(getJavaIdentifier(definition));
}
@ -247,9 +248,10 @@ public abstract class AbstractGeneratorStrategy implements GeneratorStrategy {
@Override
public final List<String> getFullJavaIdentifiers(Collection<? extends Definition> definitions) {
List<String> result = new ArrayList<String>();
List<? extends Definition> nonNull = nonNull(definitions);
List<String> result = new ArrayList<String>(nonNull.size());
for (Definition definition : nonNull(definitions)) {
for (Definition definition : nonNull) {
result.add(getFullJavaIdentifier(definition));
}
@ -310,4 +312,4 @@ public abstract class AbstractGeneratorStrategy implements GeneratorStrategy {
else
return null;
}
}
}

View File

@ -1403,8 +1403,8 @@ public class JavaGenerator extends AbstractGenerator {
}
}
List<String> arguments = new ArrayList<String>();
List<String> calls = new ArrayList<String>();
List<String> arguments = new ArrayList<String>(degree);
List<String> calls = new ArrayList<String>(degree);
for (int i = 1; i <= degree; i++) {
TypedElementDefinition<?> column = columns.get(i - 1);
@ -1459,7 +1459,7 @@ public class JavaGenerator extends AbstractGenerator {
// [#3130] Invalid UDTs may have a degree of 0
// [#3176] Avoid generating constructors for tables with more than 255 columns (Java's method argument limit)
if (degree > 0 && degree < 256) {
List<String> arguments = new ArrayList<String>();
List<String> arguments = new ArrayList<String>(degree);
for (int i = 0; i < degree; i++) {
final TypedElementDefinition<?> column = columns.get(i);
@ -2394,7 +2394,7 @@ public class JavaGenerator extends AbstractGenerator {
final String className = getStrategy().getJavaClassName(e, Mode.ENUM);
final List<String> interfaces = out.ref(getStrategy().getJavaClassImplements(e, Mode.ENUM));
final List<String> literals = e.getLiterals();
final List<String> identifiers = new ArrayList<String>();
final List<String> identifiers = new ArrayList<String>(literals.size());
for (int i = 0; i < literals.size(); i++) {
String identifier = convertToIdentifier(literals.get(i), language);
@ -3284,7 +3284,7 @@ public class JavaGenerator extends AbstractGenerator {
// [#3010] Invalid UDTs may have no attributes. Avoid generating this constructor in that case
int size = getTypedElements(tableOrUDT).size();
if (size > 0) {
List<String> nulls = new ArrayList<String>();
List<String> nulls = new ArrayList<String>(size);
for (TypedElementDefinition<?> column : getTypedElements(tableOrUDT))
// Avoid ambiguities between a single-T-value constructor

View File

@ -202,7 +202,7 @@ public class JavaWriter extends GeneratorWriter<JavaWriter> {
@Override
protected List<String> ref(List<String> clazz, int keepSegments) {
List<String> result = new ArrayList<String>();
List<String> result = new ArrayList<String>(clazz == null ? 0 : clazz.size());
if (clazz != null) {
for (String c : clazz) {

View File

@ -182,9 +182,10 @@ public class MatcherStrategy extends DefaultGeneratorStrategy {
}
private final List<String> split(String result) {
List<String> list = new ArrayList<String>();
String[] split = result.split(",");
List<String> list = new ArrayList<String>(split.length);
for (String string : result.split(","))
for (String string : split)
list.add(string.trim());
return list;

View File

@ -169,7 +169,7 @@ final class AttributeConverterExtractor implements Integrator {
}
private final List<String> entityClassNames() {
List<String> result = new ArrayList<String>();
List<String> result = new ArrayList<String>(classes.size());
for (Class<?> klass : classes)
result.add(klass.getName());

View File

@ -1335,7 +1335,7 @@ public abstract class AbstractDatabase implements Database {
}
private final List<EnumDefinition> getConfiguredEnums() {
List<EnumDefinition> result = new ArrayList<EnumDefinition>();
List<EnumDefinition> result = new ArrayList<EnumDefinition>(configuredCustomTypes.size());
for (EnumType enumType : configuredEnumTypes) {
String name = enumType.getName();

View File

@ -181,7 +181,7 @@ abstract class AbstractCursor<R extends Record> implements Formattable, Iterable
for (int index = 0; index < fields.fields.length; index++) {
if (Number.class.isAssignableFrom(fields.fields[index].getType())) {
List<Integer> decimalPlacesList = new ArrayList<Integer>();
List<Integer> decimalPlacesList = new ArrayList<Integer>(1 + buffer.size());
// Initialize
decimalPlacesList.add(0);
@ -205,7 +205,7 @@ abstract class AbstractCursor<R extends Record> implements Formattable, Iterable
colMaxWidth = isNumCol ? NUM_COL_MAX_WIDTH : format.maxColWidth();
// Collect all widths for the column
List<Integer> widthList = new ArrayList<Integer>();
List<Integer> widthList = new ArrayList<Integer>(1 + buffer.size());
// Add column name width first
widthList.add(min(colMaxWidth, max(format.minColWidth(), fields.fields[index].getName().length())));

View File

@ -573,7 +573,7 @@ abstract class AbstractDMLQuery<R extends Record> extends AbstractQuery {
case HSQLDB:
default: {
List<String> names = new ArrayList<String>();
List<String> names = new ArrayList<String>(returningResolvedAsterisks.size());
RenderNameStyle style = configuration().settings().getRenderNameStyle();
for (Field<?> field : returningResolvedAsterisks) {

View File

@ -947,7 +947,7 @@ abstract class AbstractField<T> extends AbstractNamed implements Field<T> {
@Override
public final Condition in(Collection<?> values) {
List<Field<?>> fields = new ArrayList<Field<?>>();
List<Field<?>> fields = new ArrayList<Field<?>>(values.size());
for (Object value : values)
fields.add(Tools.field(value, this));
@ -987,7 +987,7 @@ abstract class AbstractField<T> extends AbstractNamed implements Field<T> {
@Override
public final Condition notIn(Collection<?> values) {
List<Field<?>> fields = new ArrayList<Field<?>>();
List<Field<?>> fields = new ArrayList<Field<?>>(values.size());
for (Object value : values)
fields.add(Tools.field(value, this));

View File

@ -426,7 +426,7 @@ public abstract class AbstractRoutine<T> extends AbstractNamed implements Routin
private final int executeSelectFromPOSTGRES() {
DSLContext create = create(configuration);
List<Field<?>> fields = new ArrayList<Field<?>>();
List<Field<?>> fields = new ArrayList<Field<?>>(1 + outParameters.size());
if (returnParameter != null)
fields.add(DSL.field(DSL.name(getName()), returnParameter.getDataType()));
for (Parameter<?> p : outParameters)
@ -1606,7 +1606,7 @@ public abstract class AbstractRoutine<T> extends AbstractNamed implements Routin
RenderContext local = create(ctx).renderContext();
toSQLQualifiedName(local);
List<Field<?>> fields = new ArrayList<Field<?>>();
List<Field<?>> fields = new ArrayList<Field<?>>(getInParameters().size());
for (Parameter<?> parameter : getInParameters()) {
// [#1183] [#3533] Skip defaulted parameters

View File

@ -200,7 +200,7 @@ final class BatchSingle implements BatchBindStep {
// [#4062] Make sure we collect also repeated named parameters
ParamCollector collector = new ParamCollector(configuration, false);
collector.visit(query);
List<Param<?>> params = new ArrayList<Param<?>>();
List<Param<?>> params = new ArrayList<Param<?>>(collector.resultList.size());
for (Entry<String, Param<?>> entry : collector.resultList)
params.add(entry.getValue());
@ -263,7 +263,7 @@ final class BatchSingle implements BatchBindStep {
}
private final int[] executeStatic() {
List<Query> queries = new ArrayList<Query>();
List<Query> queries = new ArrayList<Query>(allBindValues.size());
for (Object[] bindValues : allBindValues) {
for (int i = 0; i < bindValues.length; i++) {

View File

@ -399,7 +399,7 @@ public abstract class DAOImpl<R extends UpdatableRecord<R>, P, T> implements DAO
}
private /* non-final */ List<R> records(Collection<P> objects, boolean forUpdate) {
List<R> result = new ArrayList<R>();
List<R> result = new ArrayList<R>(objects.size());
Field<?>[] pk = pk();
for (P object : objects) {

View File

@ -86,9 +86,9 @@ final class DDL {
}
private final List<Query> alterTableAddConstraints(Table<?> table) {
List<Query> result = new ArrayList<Query>();
for (Constraint constraint : constraints(table))
List<Constraint> constraints = constraints(table);
List<Query> result = new ArrayList<Query>(constraints.size());
for (Constraint constraint : constraints)
result.add(ctx.alterTable(table).add(constraint));
return result;

View File

@ -20642,7 +20642,7 @@ public class DSL {
*/
@Support
public static RowN row(Collection<?> values) {
Collection<Field<?>> fields = new ArrayList<Field<?>>();
Collection<Field<?>> fields = new ArrayList<Field<?>>(values.size());
for (Object o : values)
fields.add(o instanceof Field<?> ? (Field<?>) o : val(o));

View File

@ -704,10 +704,10 @@ public class DefaultDSLContext extends AbstractScope implements DSLContext, Seri
@Override
public List<Object> extractBindValues(QueryPart part) {
List<Object> result = new ArrayList<Object>();
ParamCollector collector = new ParamCollector(configuration(), false);
collector.visit(part);
List<Object> result = new ArrayList<Object>(collector.resultList.size());
for (Entry<String, Param<?>> entry : collector.resultList)
result.add(entry.getValue().getValue());
@ -1459,7 +1459,7 @@ public class DefaultDSLContext extends AbstractScope implements DSLContext, Seri
return new ResultImpl<Record>(configuration());
}
else {
List<Field<?>> fields = new ArrayList<Field<?>>();
List<Field<?>> fields = new ArrayList<Field<?>>(strings.get(0).length);
int firstRow;
if (header) {

View File

@ -391,7 +391,7 @@ public class DefaultRecordMapper<R extends Record, E> implements RecordMapper<R,
Class<?> klassType = Tools.ktKClass().type();
Method getJavaClass = jvmClassMappingKt.type().getMethod("getJavaClass", klassType);
List<String> parameterNames = new ArrayList<String>();
List<String> parameterNames = new ArrayList<String>(parameters.size());
Class<?>[] parameterTypes = new Class[parameters.size()];
for (int i = 0; i < parameterTypes.length; i++) {

View File

@ -95,7 +95,7 @@ implements
*/
private final Table<Record> table() {
ConditionProviderImpl selfJoin = new ConditionProviderImpl();
List<Field<?>> select = new ArrayList<Field<?>>();
List<Field<?>> select = new ArrayList<Field<?>>(returning.size());
Table<?> outer = dividend.as("dividend");
for (Field<?> field : returning) {

View File

@ -186,7 +186,7 @@ final class FieldMapsForInsert extends AbstractQueryPart {
Select<Record> select = null;
for (int row = 0; row < rows; row++) {
List<Field<?>> fields = new ArrayList<Field<?>>();
List<Field<?>> fields = new ArrayList<Field<?>>(values.size());
for (List<Field<?>> list : values.values())
fields.add(list.get(row));

View File

@ -646,7 +646,7 @@ final class InsertQueryImpl<R extends Record> extends AbstractStoreQuery<R> impl
// [#6462] MySQL ON DUPLICATGE KEY UPDATE clause
// All conflicting keys are considered
List<List<? extends Field<?>>> result = new ArrayList<List<? extends Field<?>>>();
List<List<? extends Field<?>>> result = new ArrayList<List<? extends Field<?>>>(table.getKeys().size());
for (UniqueKey<R> key : table.getKeys())
result.add(key.getFields());

View File

@ -101,9 +101,9 @@ final class JSONReader implements Closeable {
}
private final void readRecords(LinkedHashMap<String, LinkedList<?>> jsonRoot) {
records = new ArrayList<String[]>();
for (Object record : jsonRoot.get("records")) {
LinkedList<?> rootRecords = jsonRoot.get("records");
records = new ArrayList<String[]>(rootRecords.size());
for (Object record : rootRecords) {
String[] v = new String[fieldNames.length];
int i = 0;

View File

@ -185,11 +185,11 @@ implements
@SuppressWarnings({ "unchecked", "rawtypes" })
@Override
public final List<ForeignKey<Record, ?>> getReferences() {
List<ForeignKey<?, ?>> result = new ArrayList<ForeignKey<?, ?>>();
result.addAll(lhs.getReferences());
result.addAll(rhs.getReferences());
List<? extends ForeignKey<?, ?>> lhsReferences = lhs.getReferences();
List<? extends ForeignKey<?, ?>> rhsReferences = rhs.getReferences();
List<ForeignKey<?, ?>> result = new ArrayList<ForeignKey<?, ?>>(lhsReferences.size() + rhsReferences.size());
result.addAll(lhsReferences);
result.addAll(rhsReferences);
return (List) result;
}

View File

@ -55,6 +55,7 @@ import static org.jooq.impl.DSL.exists;
import static org.jooq.impl.DSL.insertInto;
import static org.jooq.impl.DSL.notExists;
import static org.jooq.impl.DSL.nullSafe;
import static org.jooq.impl.DSL.row;
import static org.jooq.impl.Keywords.K_AND;
import static org.jooq.impl.Keywords.K_AS;
import static org.jooq.impl.Keywords.K_DELETE_WHERE;
@ -1209,8 +1210,8 @@ implements
// ------------------------------
Table<?> src;
if (upsertSelect != null) {
List<Field<?>> v = new ArrayList<Field<?>>();
Row row = upsertSelect.fieldsRow();
List<Field<?>> v = new ArrayList<Field<?>>(row.size());
for (int i = 0; i < row.size(); i++) {
v.add(row.field(i).as("s" + (i + 1)));
@ -1221,7 +1222,7 @@ implements
src = DSL.select(v).from(upsertSelect).asTable("src");
}
else {
List<Field<?>> v = new ArrayList<Field<?>>();
List<Field<?>> v = new ArrayList<Field<?>>(getUpsertValues().size());
for (int i = 0; i < getUpsertValues().size(); i++) {
v.add(getUpsertValues().get(i).as("s" + (i + 1)));

View File

@ -382,7 +382,7 @@ final class MetaImpl extends AbstractMeta {
}
});
List<Table<?>> result = new ArrayList<Table<?>>();
List<Table<?>> result = new ArrayList<Table<?>>(tables.size());
for (Record table : tables) {
String catalog = table.get(0, String.class);
String schema = table.get(1, String.class);
@ -581,7 +581,6 @@ final class MetaImpl extends AbstractMeta {
@Override
@SuppressWarnings("unchecked")
public List<ForeignKey<Record, ?>> getReferences() {
List<ForeignKey<Record, ?>> references = new ArrayList<ForeignKey<Record, ?>>();
Result<Record> result = meta(new MetaFunction() {
@Override
public Result<Record> run(DatabaseMetaData meta) throws SQLException {
@ -620,6 +619,7 @@ final class MetaImpl extends AbstractMeta {
for (Schema schema : getSchemas())
schemas.put(schema.getName(), schema);
List<ForeignKey<Record, ?>> references = new ArrayList<ForeignKey<Record, ?>>(groups.size());
for (Entry<Record, Result<Record>> entry : groups.entrySet()) {
Schema schema = schemas.get(entry.getKey().get(1));
@ -846,7 +846,6 @@ final class MetaImpl extends AbstractMeta {
@Override
@SuppressWarnings("unchecked")
public final List<ForeignKey<?, Record>> getReferences() {
List<ForeignKey<?, Record>> references = new ArrayList<ForeignKey<?, Record>>();
Result<Record> result = meta(new MetaFunction() {
@Override
public Result<Record> run(DatabaseMetaData meta) throws SQLException {
@ -885,6 +884,7 @@ final class MetaImpl extends AbstractMeta {
for (Schema schema : getSchemas())
schemas.put(schema.getName(), schema);
List<ForeignKey<?, Record>> references = new ArrayList<ForeignKey<?, Record>>(groups.size());
for (Entry<Record, Result<Record>> entry : groups.entrySet()) {
Schema schema = schemas.get(entry.getKey().get(1));

View File

@ -169,7 +169,7 @@ final class ReferenceImpl<R extends Record, O extends Record> extends AbstractKe
* Extract a list of values from a set of records given some fields
*/
private static <R extends Record> List<Object> extractValues(Collection<? extends R> records, TableField<R, ?> field2) {
List<Object> result = new ArrayList<Object>();
List<Object> result = new ArrayList<Object>(records.size());
for (R record : records)
result.add(record.get(field2));
@ -181,7 +181,7 @@ final class ReferenceImpl<R extends Record, O extends Record> extends AbstractKe
* Extract a list of row value expressions from a set of records given some fields
*/
private static <R extends Record> List<RowN> extractRows(Collection<? extends R> records, TableField<R, ?>[] fields) {
List<RowN> rows = new ArrayList<RowN>();
List<RowN> rows = new ArrayList<RowN>(records.size());
for (R record : records) {
Object[] values = new Object[fields.length];

View File

@ -351,7 +351,7 @@ final class ResultImpl<R extends Record> extends AbstractCursor<R> implements Re
@Override
public final List<Map<String, Object>> intoMaps() {
List<Map<String, Object>> list = new ArrayList<Map<String, Object>>();
List<Map<String, Object>> list = new ArrayList<Map<String, Object>>(size());
for (R record : this)
list.add(record.intoMap());
@ -537,7 +537,7 @@ final class ResultImpl<R extends Record> extends AbstractCursor<R> implements Re
Map<List<?>, E> map = new LinkedHashMap<List<?>, E>();
for (R record : this) {
List<Object> keyValueList = new ArrayList<Object>();
List<Object> keyValueList = new ArrayList<Object>(keys.length);
for (Field<?> key : keys)
keyValueList.add(record.get(key));
@ -1399,7 +1399,7 @@ final class ResultImpl<R extends Record> extends AbstractCursor<R> implements Re
@Override
public final <E> List<E> map(RecordMapper<? super R, E> mapper) {
List<E> result = new ArrayList<E>();
List<E> result = new ArrayList<E>(size());
for (R record : this)
result.add(mapper.map(record));

View File

@ -115,7 +115,7 @@ final class RowCondition extends AbstractCondition {
// Regular comparison predicate emulation
if ((comparator == EQUALS || comparator == NOT_EQUALS) &&
EMULATE_EQ_AND_NE.contains(dialect.family())) {
List<Condition> conditions = new ArrayList<Condition>();
List<Condition> conditions = new ArrayList<Condition>(left.fields().length);
Field<?>[] leftFields = left.fields();
Field<?>[] rightFields = right.fields();
@ -156,16 +156,16 @@ final class RowCondition extends AbstractCondition {
= (comparator == GREATER_OR_EQUAL)
||(comparator == LESS_OR_EQUAL);
// The following algorithm emulates the equivalency of these expressions:
// (A, B, C) > (X, Y, Z)
// (A > X) OR (A = X AND B > Y) OR (A = X AND B = Y AND C > Z)
List<Condition> outer = new ArrayList<Condition>();
Field<?>[] leftFields = left.fields();
Field<?>[] rightFields = right.fields();
// The following algorithm emulates the equivalency of these expressions:
// (A, B, C) > (X, Y, Z)
// (A > X) OR (A = X AND B > Y) OR (A = X AND B = Y AND C > Z)
List<Condition> outer = new ArrayList<Condition>(1 + leftFields.length);
for (int i = 0; i < leftFields.length; i++) {
List<Condition> inner = new ArrayList<Condition>();
List<Condition> inner = new ArrayList<Condition>(1 + i);
for (int j = 0; j < i; j++)
inner.add(leftFields[j].equal((Field) rightFields[j]));
@ -237,4 +237,4 @@ final class RowCondition extends AbstractCondition {
return CLAUSES;
}
}
}
}

View File

@ -104,7 +104,7 @@ final class RowInCondition extends AbstractCondition {
private final QueryPartInternal delegate(Configuration configuration) {
if (EMULATE_IN.contains(configuration.family())) {
List<Condition> conditions = new ArrayList<Condition>();
List<Condition> conditions = new ArrayList<Condition>(right.size());
for (Row row : right)
conditions.add(new RowCondition(left, row, EQUALS));
@ -151,4 +151,4 @@ final class RowInCondition extends AbstractCondition {
return comparator == IN ? CLAUSES_IN : CLAUSES_IN_NOT;
}
}
}
}

View File

@ -109,7 +109,7 @@ final class RowIsNull extends AbstractCondition {
// CUBRID 9.0.0 and HSQLDB have buggy implementations of the NULL predicate.
// Informix doesn't implement the RVE IS NULL predicate.
if (EMULATE_NULL.contains(configuration.family())) {
List<Condition> conditions = new ArrayList<Condition>();
List<Condition> conditions = new ArrayList<Condition>(row.fields().length);
for (Field<?> field : row.fields())
conditions.add(isNull ? field.isNull() : field.isNotNull());
@ -141,4 +141,4 @@ final class RowIsNull extends AbstractCondition {
return isNull ? CLAUSES_NULL : CLAUSES_NOT_NULL;
}
}
}
}

View File

@ -153,7 +153,7 @@ final class RowSubqueryCondition extends AbstractCondition {
else {
String table = render == null ? "t" : render.nextAlias();
List<String> names = new ArrayList<String>();
List<String> names = new ArrayList<String>(left.size());
for (int i = 0; i < left.size(); i++)
names.add(table + "_" + i);
@ -254,4 +254,4 @@ final class RowSubqueryCondition extends AbstractCondition {
return CLAUSES;
}
}
}
}

View File

@ -101,7 +101,7 @@ final class SortFieldList extends QueryPartList<SortField<?>> {
}
final List<Field<?>> fields() {
List<Field<?>> result = new ArrayList<Field<?>>();
List<Field<?>> result = new ArrayList<Field<?>>(size());
for (SortField<?> field : this)
result.add(((SortFieldImpl<?>) field).getField());

View File

@ -87,9 +87,9 @@ final class TableAlias<R extends Record> extends AbstractTable<R> {
*/
@SuppressWarnings({ "rawtypes", "unchecked" })
private final Fields<R> init(Name[] fieldAliases) {
List<Field<?>> result = new ArrayList<Field<?>>();
Row row = this.alias.wrapped().fieldsRow();
int size = row.size();
List<Field<?>> result = new ArrayList<Field<?>>(size);
for (int i = 0; i < size; i++) {
Field<?> field = row.field(i);

View File

@ -671,7 +671,7 @@ final class Tools {
* Turn a {@link Result} into a list of {@link Row}
*/
static final List<Row> rows(Result<?> result) {
List<Row> rows = new ArrayList<Row>();
List<Row> rows = new ArrayList<Row>(result.size());
for (Record record : result)
rows.add(record.valuesRow());
@ -1421,11 +1421,12 @@ final class Tools {
* values created from the argument objects.
*/
static final <T> List<Field<T>> fields(T[] values) {
List<Field<T>> result = new ArrayList<Field<T>>();
int length = values == null ? 0 : values.length;
List<Field<T>> result = new ArrayList<Field<T>>(length);
if (values != null)
for (T value : values)
result.add(field(value));
for (int i = 0; i < length; i++) {
result.add(field(values[i]));
}
return result;
}
@ -1439,12 +1440,11 @@ final class Tools {
* values created from the argument objects.
*/
static final List<Field<?>> fields(Object[] values, Field<?> field) {
List<Field<?>> result = new ArrayList<Field<?>>();
int length = values == null || field == null ? 0 : values.length;
List<Field<?>> result = new ArrayList<Field<?>>(length);
if (values != null && field != null) {
for (int i = 0; i < values.length; i++) {
result.add(field(values[i], field));
}
for (int i = 0; i < length; i++) {
result.add(field(values[i], field));
}
return result;
@ -1459,12 +1459,11 @@ final class Tools {
* values created from the argument objects.
*/
static final List<Field<?>> fields(Object[] values, Field<?>[] fields) {
List<Field<?>> result = new ArrayList<Field<?>>();
int length = values == null || fields == null ? 0 : Math.min(values.length, fields.length);
List<Field<?>> result = new ArrayList<Field<?>>(length);
if (values != null && fields != null) {
for (int i = 0; i < values.length && i < fields.length; i++) {
result.add(field(values[i], fields[i]));
}
for (int i = 0; i < length; i++) {
result.add(field(values[i], fields[i]));
}
return result;
@ -1479,12 +1478,11 @@ final class Tools {
* values created from the argument objects.
*/
static final List<Field<?>> fields(Object[] values, Class<?> type) {
List<Field<?>> result = new ArrayList<Field<?>>();
int length = values == null || type == null ? 0 : values.length;
List<Field<?>> result = new ArrayList<Field<?>>(length);
if (values != null && type != null) {
for (int i = 0; i < values.length; i++) {
result.add(field(values[i], type));
}
for (int i = 0; i < length; i++) {
result.add(field(values[i], type));
}
return result;
@ -1499,12 +1497,11 @@ final class Tools {
* values created from the argument objects.
*/
static final List<Field<?>> fields(Object[] values, Class<?>[] types) {
List<Field<?>> result = new ArrayList<Field<?>>();
int length = values == null || types == null ? 0 : Math.min(values.length, types.length);
List<Field<?>> result = new ArrayList<Field<?>>(length);
if (values != null && types != null) {
for (int i = 0; i < values.length && i < types.length; i++) {
result.add(field(values[i], types[i]));
}
for (int i = 0; i < length; i++) {
result.add(field(values[i], types[i]));
}
return result;
@ -1519,12 +1516,11 @@ final class Tools {
* values created from the argument objects.
*/
static final List<Field<?>> fields(Object[] values, DataType<?> type) {
List<Field<?>> result = new ArrayList<Field<?>>();
int length = values == null || type == null ? 0 : values.length;
List<Field<?>> result = new ArrayList<Field<?>>(length);
if (values != null && type != null) {
for (int i = 0; i < values.length; i++) {
result.add(field(values[i], type));
}
for (int i = 0; i < length; i++) {
result.add(field(values[i], type));
}
return result;
@ -1539,21 +1535,23 @@ final class Tools {
* values created from the argument objects.
*/
static final List<Field<?>> fields(Object[] values, DataType<?>[] types) {
List<Field<?>> result = new ArrayList<Field<?>>();
int length = values == null || types == null ? 0 : Math.min(values.length, types.length);
List<Field<?>> result = new ArrayList<Field<?>>(length);
if (values != null && types != null)
for (int i = 0; i < values.length && i < types.length; i++)
result.add(field(values[i], types[i]));
for (int i = 0; i < length; i++) {
result.add(field(values[i], types[i]));
}
return result;
}
static final <T> List<Field<T>> inline(T[] values) {
List<Field<T>> result = new ArrayList<Field<T>>();
int length = values == null ? 0 : values.length;
List<Field<T>> result = new ArrayList<Field<T>>(length);
if (values != null)
for (T value : values)
result.add(DSL.inline(value));
for (int i = 0; i < length; i++) {
result.add(DSL.inline(values[i]));
}
return result;
}
@ -2230,7 +2228,7 @@ final class Tools {
return queryParts(new Object[] { null });
}
else {
List<QueryPart> result = new ArrayList<QueryPart>();
List<QueryPart> result = new ArrayList<QueryPart>(substitutes.length);
for (Object substitute : substitutes) {

View File

@ -173,7 +173,7 @@ public class LoggerListener extends DefaultExecuteListener {
private Record record(Configuration configuration, Routine<?> routine) {
Record result = null;
List<Field<?>> fields = new ArrayList<Field<?>>();
List<Field<?>> fields = new ArrayList<Field<?>>(1 + routine.getOutParameters().size());
Parameter<?> returnParam = routine.getReturnParameter();
if (returnParam != null)
fields.add(field(name(returnParam.getName()), returnParam.getDataType()));

View File

@ -48,6 +48,7 @@ Authors and contributors of jOOQ or parts of jOOQ in alphabetical order:
- Sven Jacobs
- Szymon Jachim
- Terence Zhang
- Timothy Wilson
- Timur Shaidullin
- Thomas Darimont
- Tsukasa Kitachi