-
Notifications
You must be signed in to change notification settings - Fork 75
refactor: Optimize Java Implementation #1545
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
MarkDuckworth
left a comment
There was a problem hiding this 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()); |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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 { |
There was a problem hiding this comment.
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; |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed
|
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. |
Optimizations:
builderWithExpectedSizewhen possible.Preconditions.checkArgumentto avoid building strings unless required.SortedMaporImmutableListwas required, but a different type was originally created.equalsmethod. Instead, compare values directly.QueryDocumentSnapshotcomparator. We should avoid creating objects as part of comparison.String.joininstead of rolling our own.compareTowhen==.