Skip to content

Conversation

@tom-andersen
Copy link
Contributor

@tom-andersen tom-andersen commented Jan 24, 2024

Optimizations:

  • Use builderWithExpectedSize when possible.
  • Create a local variable instead of calling method multiple times.
  • Remove dead code.
  • Use template for Preconditions.checkArgument to avoid building strings unless required.
  • Avoid copying collections because SortedMap or ImmutableList was required, but a different type was originally created.
  • Introduce constants instead of repeatedly building the same objects.
  • Avoid converting to proto as part of equals method. Instead, compare values directly.
  • Simplify and optimize QueryDocumentSnapshot comparator. We should avoid creating objects as part of comparison.
  • Use String.join instead of rolling our own.
  • Short circuit compareTo when ==.
  • Create specialized methods instead of having conditional code paths within the method.
  • Remove dead class.

@product-auto-label product-auto-label bot added size: m Pull request size is medium. api: firestore Issues related to the googleapis/java-firestore API. labels Jan 24, 2024
@product-auto-label product-auto-label bot added size: l Pull request size is large. and removed size: m Pull request size is medium. labels Jan 25, 2024
@tom-andersen tom-andersen marked this pull request as ready for review January 25, 2024 21:20
@tom-andersen tom-andersen requested review from a team as code owners January 25, 2024 21:20
Copy link
Contributor

@MarkDuckworth MarkDuckworth left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM with comments for your consideration

/** Returns the number of path components. */
int size() {
return this.getSegments().size();
return Integer.compare(thisSegments.size(), otherSegments.size());
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: in the spirit of optimization, you can compare size first before iterating path segments and comparing strings.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That would work for equals, but compare needs to determine order.


/** A Firestore BulkWriter that can be used to perform a large number of writes in parallel. */
@BetaApi
public final class BulkWriter implements AutoCloseable {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Bringing BulkWriter out of beta, is that worthy of a minor version bump in the commit message

feat: BulkWriter out of beta

}
FieldOrder filter = (FieldOrder) o;
return Objects.equals(toProto(), filter.toProto());
if (direction != filter.direction) return false;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ultraNit. May as well use brackets consistently with the other conditionals.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed

@tom-andersen tom-andersen added the owlbot:run Add this label to trigger the Owlbot post processor. label Jan 27, 2024
@gcf-owl-bot gcf-owl-bot bot removed the owlbot:run Add this label to trigger the Owlbot post processor. label Jan 27, 2024
@tom-andersen tom-andersen added the automerge Merge the pull request once unit tests and other checks pass. label Jan 27, 2024
@gcf-merge-on-green
Copy link
Contributor

Merge-on-green attempted to merge your PR for 6 hours, but it was not mergeable because either one of your required status checks failed, one of your required reviews was not approved, or there is a do not merge label. Learn more about your required status checks here: https://help.github.com/en/github/administering-a-repository/enabling-required-status-checks. You can remove and reapply the label to re-run the bot.

@gcf-merge-on-green gcf-merge-on-green bot removed the automerge Merge the pull request once unit tests and other checks pass. label Jan 27, 2024
@tom-andersen tom-andersen added the kokoro:force-run Add this label to force Kokoro to re-run the tests. label Jan 29, 2024
@yoshi-kokoro yoshi-kokoro removed the kokoro:force-run Add this label to force Kokoro to re-run the tests. label Jan 29, 2024
@tom-andersen tom-andersen merged commit 29b472d into main Jan 29, 2024
@tom-andersen tom-andersen deleted the tomandersen/refactorBadJava branch January 29, 2024 17:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

api: firestore Issues related to the googleapis/java-firestore API. size: l Pull request size is large.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants