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
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 3 additions & 16 deletions Examples/Java/Sources/Board.java
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ public class Board {
static final private int NAME_INDEX = 8;
static final private int URL_INDEX = 9;

private boolean[] _bits = new boolean[10];
private boolean[] _bits;

private Board(
@Nullable String uid,
Expand Down Expand Up @@ -223,9 +223,10 @@ public static class Builder {
private @Nullable String name;
private @Nullable String url;

private boolean[] _bits = new boolean[10];
private boolean[] _bits;

private Builder() {
this._bits = new boolean[10];
}

private Builder(@NonNull Board model) {
Expand Down Expand Up @@ -557,7 +558,6 @@ public Board read(@NonNull JsonReader reader) throws IOException {
return null;
}
Builder builder = Board.builder();
boolean[] bits = null;
reader.beginObject();
while (reader.hasNext()) {
String name = reader.nextName();
Expand Down Expand Up @@ -622,24 +622,11 @@ public Board read(@NonNull JsonReader reader) throws IOException {
}
builder.setUrl(this.stringTypeAdapter.read(reader));
break;
case ("_bits"):
bits = new boolean[10];
int i = 0;
reader.beginArray();
while (reader.hasNext() && i < 10) {
bits[i] = reader.nextBoolean();
i++;
}
reader.endArray();
break;
default:
reader.skipValue();
}
}
reader.endObject();
if (bits != null) {
builder._bits = bits;
}
return builder.build();
}
}
Expand Down
19 changes: 3 additions & 16 deletions Examples/Java/Sources/Everything.java
Original file line number Diff line number Diff line change
Expand Up @@ -222,7 +222,7 @@ public int getValue() {
static final private int UNSIGNED_SHORT_ENUM_INDEX = 34;
static final private int URI_PROP_INDEX = 35;

private boolean[] _bits = new boolean[36];
private boolean[] _bits;

private Everything(
@Nullable List<Object> arrayProp,
Expand Down Expand Up @@ -736,9 +736,10 @@ public static class Builder {
private @Nullable EverythingUnsignedShortEnum unsignedShortEnum;
private @Nullable String uriProp;

private boolean[] _bits = new boolean[36];
private boolean[] _bits;

private Builder() {
this._bits = new boolean[36];
}

private Builder(@NonNull Everything model) {
Expand Down Expand Up @@ -1799,7 +1800,6 @@ public Everything read(@NonNull JsonReader reader) throws IOException {
return null;
}
Builder builder = Everything.builder();
boolean[] bits = null;
reader.beginObject();
while (reader.hasNext()) {
String name = reader.nextName();
Expand Down Expand Up @@ -2020,24 +2020,11 @@ public Everything read(@NonNull JsonReader reader) throws IOException {
}
builder.setUriProp(this.stringTypeAdapter.read(reader));
break;
case ("_bits"):
bits = new boolean[36];
int i = 0;
reader.beginArray();
while (reader.hasNext() && i < 36) {
bits[i] = reader.nextBoolean();
i++;
}
reader.endArray();
break;
default:
reader.skipValue();
}
}
reader.endObject();
if (bits != null) {
builder._bits = bits;
}
return builder.build();
}
}
Expand Down
19 changes: 3 additions & 16 deletions Examples/Java/Sources/Image.java
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ public class Image {
static final private int URL_INDEX = 1;
static final private int WIDTH_INDEX = 2;

private boolean[] _bits = new boolean[3];
private boolean[] _bits;

private Image(
@Nullable Integer height,
Expand Down Expand Up @@ -117,9 +117,10 @@ public static class Builder {
private @Nullable String url;
private @Nullable Integer width;

private boolean[] _bits = new boolean[3];
private boolean[] _bits;

private Builder() {
this._bits = new boolean[3];
}

private Builder(@NonNull Image model) {
Expand Down Expand Up @@ -258,7 +259,6 @@ public Image read(@NonNull JsonReader reader) throws IOException {
return null;
}
Builder builder = Image.builder();
boolean[] bits = null;
reader.beginObject();
while (reader.hasNext()) {
String name = reader.nextName();
Expand All @@ -281,24 +281,11 @@ public Image read(@NonNull JsonReader reader) throws IOException {
}
builder.setWidth(this.integerTypeAdapter.read(reader));
break;
case ("_bits"):
bits = new boolean[3];
int i = 0;
reader.beginArray();
while (reader.hasNext() && i < 3) {
bits[i] = reader.nextBoolean();
i++;
}
reader.endArray();
break;
default:
reader.skipValue();
}
}
reader.endObject();
if (bits != null) {
builder._bits = bits;
}
return builder.build();
}
}
Expand Down
19 changes: 3 additions & 16 deletions Examples/Java/Sources/Model.java
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ public class Model {

static final private int ID_INDEX = 0;

private boolean[] _bits = new boolean[1];
private boolean[] _bits;

private Model(
@Nullable String uid,
Expand Down Expand Up @@ -85,9 +85,10 @@ public static class Builder {

private @Nullable String uid;

private boolean[] _bits = new boolean[1];
private boolean[] _bits;

private Builder() {
this._bits = new boolean[1];
}

private Builder(@NonNull Model model) {
Expand Down Expand Up @@ -171,7 +172,6 @@ public Model read(@NonNull JsonReader reader) throws IOException {
return null;
}
Builder builder = Model.builder();
boolean[] bits = null;
reader.beginObject();
while (reader.hasNext()) {
String name = reader.nextName();
Expand All @@ -182,24 +182,11 @@ public Model read(@NonNull JsonReader reader) throws IOException {
}
builder.setUid(this.stringTypeAdapter.read(reader));
break;
case ("_bits"):
bits = new boolean[1];
int i = 0;
reader.beginArray();
while (reader.hasNext() && i < 1) {
bits[i] = reader.nextBoolean();
i++;
}
reader.endArray();
break;
default:
reader.skipValue();
}
}
reader.endObject();
if (bits != null) {
builder._bits = bits;
}
return builder.build();
}
}
Expand Down
19 changes: 3 additions & 16 deletions Examples/Java/Sources/Pin.java
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ public int getValue() {
static final private int URL_INDEX = 15;
static final private int VISUAL_SEARCH_ATTRS_INDEX = 16;

private boolean[] _bits = new boolean[17];
private boolean[] _bits;

private Pin(
@Nullable Map<String, String> attribution,
Expand Down Expand Up @@ -346,9 +346,10 @@ public static class Builder {
private @Nullable String url;
private @Nullable Map<String, Object> visualSearchAttrs;

private boolean[] _bits = new boolean[17];
private boolean[] _bits;

private Builder() {
this._bits = new boolean[17];
}

private Builder(@NonNull Pin model) {
Expand Down Expand Up @@ -874,7 +875,6 @@ public Pin read(@NonNull JsonReader reader) throws IOException {
return null;
}
Builder builder = Pin.builder();
boolean[] bits = null;
reader.beginObject();
while (reader.hasNext()) {
String name = reader.nextName();
Expand Down Expand Up @@ -981,24 +981,11 @@ public Pin read(@NonNull JsonReader reader) throws IOException {
}
builder.setVisualSearchAttrs(this.map_String__Object_TypeAdapter.read(reader));
break;
case ("_bits"):
bits = new boolean[17];
int i = 0;
reader.beginArray();
while (reader.hasNext() && i < 17) {
bits[i] = reader.nextBoolean();
i++;
}
reader.endArray();
break;
default:
reader.skipValue();
}
}
reader.endObject();
if (bits != null) {
builder._bits = bits;
}
return builder.build();
}
}
Expand Down
19 changes: 3 additions & 16 deletions Examples/Java/Sources/User.java
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ public enum UserEmailFrequency {
static final private int TYPE_INDEX = 8;
static final private int USERNAME_INDEX = 9;

private boolean[] _bits = new boolean[10];
private boolean[] _bits;

private User(
@Nullable String bio,
Expand Down Expand Up @@ -226,9 +226,10 @@ public static class Builder {
private @Nullable String type;
private @Nullable String username;

private boolean[] _bits = new boolean[10];
private boolean[] _bits;

private Builder() {
this._bits = new boolean[10];
}

private Builder(@NonNull User model) {
Expand Down Expand Up @@ -559,7 +560,6 @@ public User read(@NonNull JsonReader reader) throws IOException {
return null;
}
Builder builder = User.builder();
boolean[] bits = null;
reader.beginObject();
while (reader.hasNext()) {
String name = reader.nextName();
Expand Down Expand Up @@ -624,24 +624,11 @@ public User read(@NonNull JsonReader reader) throws IOException {
}
builder.setUsername(this.stringTypeAdapter.read(reader));
break;
case ("_bits"):
bits = new boolean[10];
int i = 0;
reader.beginArray();
while (reader.hasNext() && i < 10) {
bits[i] = reader.nextBoolean();
i++;
}
reader.endArray();
break;
default:
reader.skipValue();
}
}
reader.endObject();
if (bits != null) {
builder._bits = bits;
}
return builder.build();
}
}
Expand Down
19 changes: 3 additions & 16 deletions Examples/Java/Sources/VariableSubtitution.java
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ public class VariableSubtitution {
static final private int MUTABLE_COPY_PROP_INDEX = 2;
static final private int NEW_PROP_INDEX = 3;

private boolean[] _bits = new boolean[4];
private boolean[] _bits;

private VariableSubtitution(
@Nullable Integer allocProp,
Expand Down Expand Up @@ -134,9 +134,10 @@ public static class Builder {
private @Nullable Integer mutableCopyProp;
private @Nullable Integer newProp;

private boolean[] _bits = new boolean[4];
private boolean[] _bits;

private Builder() {
this._bits = new boolean[4];
}

private Builder(@NonNull VariableSubtitution model) {
Expand Down Expand Up @@ -301,7 +302,6 @@ public VariableSubtitution read(@NonNull JsonReader reader) throws IOException {
return null;
}
Builder builder = VariableSubtitution.builder();
boolean[] bits = null;
reader.beginObject();
while (reader.hasNext()) {
String name = reader.nextName();
Expand Down Expand Up @@ -330,24 +330,11 @@ public VariableSubtitution read(@NonNull JsonReader reader) throws IOException {
}
builder.setNewProp(this.integerTypeAdapter.read(reader));
break;
case ("_bits"):
bits = new boolean[4];
int i = 0;
reader.beginArray();
while (reader.hasNext() && i < 4) {
bits[i] = reader.nextBoolean();
i++;
}
reader.endArray();
break;
default:
reader.skipValue();
}
}
reader.endObject();
if (bits != null) {
builder._bits = bits;
}
return builder.build();
}
}
Expand Down
Loading