Skip to content

Unreasonably large configuration performance overhead #348

Description

@oehme

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.

Activity

  1. nedtwigg commented on Feb 8, 2019

    @nedtwigg
    Member

    I think that line is using this static import:

    import static com.diffplug.gradle.spotless.PluginGradlePreconditions.requireElementsNonNull;

    Which then calls this:

    @SafeVarargs
    static <T> T[] requireElementsNonNull(T... elements) {
    Objects.requireNonNull(elements);
    for (T element : elements) {
    Objects.requireNonNull(element);
    }
    return elements;
    }

    not this:

    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).

  2. oehme commented on Feb 8, 2019

    @oehme
    Author

    Sorry, I had linked the wrong line. Here is the real culprit:

    this.target = requireElementsNonNull(target);

  3. nedtwigg commented on Feb 8, 2019

    @nedtwigg
    Member

    Aha! Thanks very much for the bug find 👍

  4. added a commit that references this issue on Feb 9, 2019
    eda5b8e
  5. jbduncan commented on Feb 11, 2019

    @jbduncan
    Member

    Oh, oops! The use of requireElementsNonNull was my doing, so thank you @oehme for submitting the bug report, and thank you very much @nedtwigg for rectifying it for me!

  6. nedtwigg commented on Feb 12, 2019

    @nedtwigg
    Member

    Published in 3.18.0

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions