Skip to content
This repository has been archived by the owner on Oct 16, 2024. It is now read-only.

Share ImmutableSets #203

Merged
merged 2 commits into from
Oct 11, 2016
Merged

Share ImmutableSets #203

merged 2 commits into from
Oct 11, 2016

Conversation

alicederyn
Copy link
Collaborator

mergeFrom now reuses ImmutableSet instances where possible, reducing the memory overhead of the modify-rebuild pattern.

This PR is part of issue #169.

mergeFrom now reuses ImmutableSet instances where possible, reducing the memory overhead of the modify-rebuild pattern.
Copy link
Collaborator

@j-baker j-baker left a comment

Choose a reason for hiding this comment

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

oh, sorry chris, I was done on this when I talked to you last week.

.addLine("public %s<%s> %s() {", Set.class, elementType, getter(property));
if (code.feature(GUAVA).isAvailable()) {
code.addLine(" if (%s instanceof %s) {", property.getName(), ImmutableSet.class)
.addLine(" %1$s = new %2$s%3$s(%1$s);",
Copy link
Collaborator

Choose a reason for hiding this comment

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

indentation

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Done

.addLine("public %s %s() {", metadata.getBuilder(), clearMethod(property));
if (code.feature(GUAVA).isAvailable()) {
code.addLine("if (%s instanceof %s) {", property.getName(), ImmutableSet.class)
.addLine(" %s = %s.of();", property.getName(), ImmutableSet.class)
Copy link
Collaborator

Choose a reason for hiding this comment

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

indentation

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Done

@j-baker j-baker merged commit a465475 into master Oct 11, 2016
@j-baker j-baker deleted the shared.sets branch October 11, 2016 12:01
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants