We're using List.of in many places in the code, this is inefficient as it could cause unnecessary copies when used in conjunction with ImmutableList as in ImmutableList.copyOf.
Here is a excerpt of a simple grep command that shows such instantiations:
fdb-record-layer-core/src/main/java/com/apple/foundationdb/record/provider/foundationdb/IndexingMerger.java: return List.of(
fdb-record-layer-core/src/main/java/com/apple/foundationdb/record/query/plan/cascades/PreOrderIterator.java: stack.push(MutablePair.of(List.of(traversable.getThis()), INITIAL_POSITION));
fdb-record-layer-core/src/main/java/com/apple/foundationdb/record/query/plan/cascades/expressions/GroupByExpression.java: List.of("AGG {{agg}}"),
fdb-record-layer-core/src/main/java/com/apple/foundationdb/record/query/plan/cascades/expressions/GroupByExpression.java: List.of("AGG {{agg}}", "GROUP BY {{grouping}}"),
fdb-record-layer-core/src/main/java/com/apple/foundationdb/record/query/plan/cascades/typing/Type.java: Type wrapperType = Record.fromFields(List.of(Record.Field.of(new Array(elementType), Optional.of(NullableArrayTypeUtils.getRepeatedFieldName()))));
fdb-record-layer-core/src/main/java/com/apple/foundationdb/record/query/plan/cascades/typing/Type.java: Type wrapperType = Record.fromFields(List.of(Record.Field.of(new Array(elementType), Optional.of(NullableArrayTypeUtils.getRepeatedFieldName()))));
fdb-record-layer-core/src/main/java/com/apple/foundationdb/record/query/plan/cascades/values/AndOrValue.java: List.of(Type.primitiveType(Type.TypeCode.BOOLEAN), Type.primitiveType(Type.TypeCode.BOOLEAN)),
fdb-record-layer-core/src/main/java/com/apple/foundationdb/record/query/plan/cascades/values/InOpValue.java: List.of(new Type.Any(), new Type.Array()), (builtInFunc, args) -> encapsulateInternal(args));
fdb-record-layer-core/src/main/java/com/apple/foundationdb/record/query/plan/cascades/values/JavaCallFunction.java: super("java_call", List.of(Type.primitiveType(Type.TypeCode.STRING)), new Type.Any(), JavaCallFunction::findFunction);
fdb-record-layer-core/src/main/java/com/apple/foundationdb/record/query/plan/cascades/values/RelOpValue.java: List.of(new Type.Any(), new Type.Any()), EqualsFn::encapsulate);
fdb-record-layer-core/src/main/java/com/apple/foundationdb/record/query/plan/cascades/values/RelOpValue.java: List.of(new Type.Any(), new Type.Any()), NotEqualsFn::encapsulate);
fdb-record-layer-core/src/main/java/com/apple/foundationdb/record/query/plan/cascades/values/RelOpValue.java: List.of(new Type.Any(), new Type.Any()), LtFn::encapsulate);
fdb-record-layer-core/src/main/java/com/apple/foundationdb/record/query/plan/cascades/values/RelOpValue.java: List.of(new Type.Any(), new Type.Any()), LteFn::encapsulate);
fdb-record-layer-core/src/main/java/com/apple/foundationdb/record/query/plan/cascades/values/RelOpValue.java: List.of(new Type.Any(), new Type.Any()), GtFn::encapsulate);
fdb-record-layer-core/src/main/java/com/apple/foundationdb/record/query/plan/cascades/values/RelOpValue.java: List.of(new Type.Any(), new Type.Any()), GteFn::encapsulate);
fdb-record-layer-core/src/main/java/com/apple/foundationdb/record/query/plan/cascades/values/RelOpValue.java: List.of(new Type.Any()), IsNullFn::encapsulate);
fdb-record-layer-core/src/main/java/com/apple/foundationdb/record/query/plan/cascades/values/RelOpValue.java: List.of(new Type.Any()), NotNullFn::encapsulate);
fdb-record-layer-core/src/main/java/com/apple/foundationdb/record/query/plan/cascades/values/UdfFunction.java: super("", List.of(), (builtInFunction, arguments) -> null);
fdb-record-layer-core/src/main/java/com/apple/foundationdb/record/query/plan/plans/RecordQueryComparatorPlan.java: List.of("COMPARE BY {{comparisonKey}}"),
fdb-record-layer-core/src/main/java/com/apple/foundationdb/record/query/plan/plans/RecordQuerySelectorPlan.java: List.of("SELECT BY {{planSelector}}"),
fdb-record-layer-core/src/test/java/com/apple/foundationdb/record/metadata/expressions/AbsoluteValueFunctionKeyExpression.java: return List.of(Key.Evaluated.scalar(value), Key.Evaluated.scalar(-1L * value));
fdb-record-layer-core/src/test/java/com/apple/foundationdb/record/metadata/expressions/AbsoluteValueFunctionKeyExpression.java: return List.of(new Builder());
fdb-record-layer-core/src/test/java/com/apple/foundationdb/record/metadata/expressions/IntWrappingFunction.java: return List.of(new Builder());
fdb-record-layer-core/src/test/java/com/apple/foundationdb/record/provider/foundationdb/query/DualPlannerExtension.java: this.extensions = List.of(setPlannerExtension(useCascadesPlanner));
fdb-record-layer-lucene/src/main/java/com/apple/foundationdb/record/lucene/LuceneScanSpellCheckParameters.java: fields = List.of(fieldAndWord[0]);
fdb-record-layer-lucene/src/main/java/com/apple/foundationdb/record/lucene/directory/FieldInfosStorage.java: wrappingDirectory.sync(List.of(fileName));
fdb-record-layer-lucene/src/main/java/com/apple/foundationdb/record/lucene/idformat/RecordIdFormat.java: return new TupleElement(List.of(children));
We're using
List.of
in many places in the code, this is inefficient as it could cause unnecessary copies when used in conjunction withImmutableList
as inImmutableList.copyOf
.Here is a excerpt of a simple
grep
command that shows such instantiations: