Repository navigation
Unreasonably large configuration performance overhead #348
Description
Activity
I think that line is using this static import:
spotless/plugin-gradle/src/main/java/com/diffplug/gradle/spotless/FormatExtension.java
Line 18 in b38ee5a
import static com.diffplug.gradle.spotless.PluginGradlePreconditions.requireElementsNonNull; Which then calls this:
spotless/plugin-gradle/src/main/java/com/diffplug/gradle/spotless/PluginGradlePreconditions.java
Lines 24 to 31 in b38ee5a
@SafeVarargs static <T> T[] requireElementsNonNull(T... elements) { Objects.requireNonNull(elements); for (T element : elements) { Objects.requireNonNull(element); } return elements; } not this:
spotless/plugin-gradle/src/main/java/com/diffplug/gradle/spotless/PluginGradlePreconditions.java
Lines 33 to 39 in b38ee5a
static <T, I extends Iterable<T>> I requireElementsNonNull(I elements) { Objects.requireNonNull(elements); for (Object element : elements) { Objects.requireNonNull(element); } return elements; } because target is an
Object[], but I might be making a mistake. So I think it's only iterating over (N filecollections), not (file collection of size N).Sorry, I had linked the wrong line. Here is the real culprit:
spotless/plugin-gradle/src/main/java/com/diffplug/gradle/spotless/SpotlessTask.java
Line 118 in 249d3ca
this.target = requireElementsNonNull(target); Aha! Thanks very much for the bug find 👍
- added a commit that references this issue
on Feb 9, 2019 Published in 3.18.0
This line iterates the whole file collection, no matter if the task will execute or not. This is a large performance overhead, paid on every build invocation, no matter if spotless will be used or not. It should instead only check wether the collection itself is null.
spotless/plugin-gradle/src/main/java/com/diffplug/gradle/spotless/FormatExtension.java
Line 135 in b38ee5a