Skip to content

Commit

Permalink
Improve formatting (#2505)
Browse files Browse the repository at this point in the history
* Improve formatting

* Move `&&` to start of line
  • Loading branch information
Marcono1234 committed Oct 3, 2023
1 parent 0109f45 commit df01e94
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 15 deletions.
8 changes: 4 additions & 4 deletions gson/src/main/java/com/google/gson/GsonBuilder.java
Original file line number Diff line number Diff line change
Expand Up @@ -675,7 +675,7 @@ public GsonBuilder registerTypeAdapter(Type type, Object typeAdapter) {
|| typeAdapter instanceof InstanceCreator<?>
|| typeAdapter instanceof TypeAdapter<?>);

if (isTypeObjectOrJsonElement(type)){
if (isTypeObjectOrJsonElement(type)) {
throw new IllegalArgumentException("Cannot override built-in adapter for " + type);
}

Expand All @@ -695,9 +695,9 @@ public GsonBuilder registerTypeAdapter(Type type, Object typeAdapter) {
}

private boolean isTypeObjectOrJsonElement(Type type) {
return type instanceof Class &&
(type == Object.class
|| JsonElement.class.isAssignableFrom((Class<?>) type));
return type instanceof Class
&& (type == Object.class
|| JsonElement.class.isAssignableFrom((Class<?>) type));
}

/**
Expand Down
4 changes: 2 additions & 2 deletions gson/src/main/java/com/google/gson/stream/JsonReader.java
Original file line number Diff line number Diff line change
Expand Up @@ -804,7 +804,7 @@ private int peekNumber() throws IOException {
// We've read a complete number. Decide if it's a PEEKED_LONG or a PEEKED_NUMBER.
// Don't store -0 as long; user might want to read it as double -0.0
// Don't try to convert Long.MIN_VALUE to positive long; it would overflow MAX_VALUE
if (last == NUMBER_CHAR_DIGIT && fitsInLong && (value != Long.MIN_VALUE || negative) && (value!=0 || !negative)) {
if (last == NUMBER_CHAR_DIGIT && fitsInLong && (value != Long.MIN_VALUE || negative) && (value != 0 || !negative)) {
peekedLong = negative ? value : -value;
pos += i;
return peeked = PEEKED_LONG;
Expand Down Expand Up @@ -1755,7 +1755,7 @@ private void consumeNonExecutePrefix() throws IOException {

int p = pos;
char[] buf = buffer;
if(buf[p] != ')' || buf[p + 1] != ']' || buf[p + 2] != '}' || buf[p + 3] != '\'' || buf[p + 4] != '\n') {
if (buf[p] != ')' || buf[p + 1] != ']' || buf[p + 2] != '}' || buf[p + 3] != '\'' || buf[p + 4] != '\n') {
return; // not a security token!
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ public void timeBagOfPrimitivesStreaming(int reps) throws IOException {
int intValue = 0;
boolean booleanValue = false;
String stringValue = null;
while(jr.hasNext()) {
while (jr.hasNext()) {
String name = jr.nextName();
if (name.equals("longValue")) {
longValue = jr.nextLong();
Expand Down Expand Up @@ -96,7 +96,7 @@ public void timeBagOfPrimitivesReflectionStreaming(int reps) throws Exception {
JsonReader jr = new JsonReader(reader);
jr.beginObject();
BagOfPrimitives bag = new BagOfPrimitives();
while(jr.hasNext()) {
while (jr.hasNext()) {
String name = jr.nextName();
for (Field field : BagOfPrimitives.class.getDeclaredFields()) {
if (field.getName().equals(name)) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ void setUp() throws Exception {
* Benchmark to measure Gson performance for deserializing an object
*/
public void timeCollectionsDefault(int reps) {
for (int i=0; i<reps; ++i) {
for (int i = 0; i < reps; ++i) {
gson.fromJson(json, LIST_TYPE_TOKEN);
}
}
Expand All @@ -66,18 +66,18 @@ public void timeCollectionsDefault(int reps) {
*/
@SuppressWarnings("ModifiedButNotUsed")
public void timeCollectionsStreaming(int reps) throws IOException {
for (int i=0; i<reps; ++i) {
for (int i = 0; i < reps; ++i) {
StringReader reader = new StringReader(json);
JsonReader jr = new JsonReader(reader);
jr.beginArray();
List<BagOfPrimitives> bags = new ArrayList<>();
while(jr.hasNext()) {
while (jr.hasNext()) {
jr.beginObject();
long longValue = 0;
int intValue = 0;
boolean booleanValue = false;
String stringValue = null;
while(jr.hasNext()) {
while (jr.hasNext()) {
String name = jr.nextName();
if (name.equals("longValue")) {
longValue = jr.nextLong();
Expand Down Expand Up @@ -105,15 +105,15 @@ public void timeCollectionsStreaming(int reps) throws IOException {
*/
@SuppressWarnings("ModifiedButNotUsed")
public void timeCollectionsReflectionStreaming(int reps) throws Exception {
for (int i=0; i<reps; ++i) {
for (int i = 0; i < reps; ++i) {
StringReader reader = new StringReader(json);
JsonReader jr = new JsonReader(reader);
jr.beginArray();
List<BagOfPrimitives> bags = new ArrayList<>();
while(jr.hasNext()) {
while (jr.hasNext()) {
jr.beginObject();
BagOfPrimitives bag = new BagOfPrimitives();
while(jr.hasNext()) {
while (jr.hasNext()) {
String name = jr.nextName();
for (Field field : BagOfPrimitives.class.getDeclaredFields()) {
if (field.getName().equals(name)) {
Expand Down

0 comments on commit df01e94

Please sign in to comment.