Skip to content
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

Only allocate _bits when necessary #238

Merged
merged 1 commit into from
Aug 24, 2019
Merged

Conversation

jparise
Copy link
Contributor

@jparise jparise commented Aug 23, 2019

We were previously allocating the _bits array as part of its
declaration. In many cases, we wouldn't use this memory; we would
just reassign _bits in the non-default constructors and builders.

Instead, we now only allocate _bits in the default Builder constructor.
We also now generate a default public model constructor when package-
private setters are enabled so that there's some backing storage to
support those set methods. (Note that we don't currently appear to
actually update _bits in those methods, which may be a separate issue.)

Lastly, we no longer need to read the "_bits" array in TypeAdapter#read,
so remove that case entirely.

@jparise jparise requested review from rahul-malik and RicoYao August 23, 2019 22:27
We were previously allocating the _bits array as part of its
declaration. In many cases, we wouldn't use this memory; we would
just reassign _bits in the non-default constructors and builders.

Instead, we now only allocate _bits in the default Builder constructor.
We also now generate a default public model constructor when package-
private setters are enabled so that there's some backing storage to
support those set methods. (Note that we don't currently appear to
actually update _bits in those methods, which may be a separate issue.)

Lastly, we no longer need to read the "_bits" array in TypeAdapter#read,
so remove that case entirely.
Copy link
Contributor

@RicoYao RicoYao left a comment

Choose a reason for hiding this comment

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

LGTM!

@jparise jparise merged commit 690a266 into pinterest:master Aug 24, 2019
@jparise jparise deleted the java-bits branch August 24, 2019 02:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants