Skip to content

Commit 2c810d5

Browse files
awturnerjeanbza
authored andcommitted
Replace occurrences of Wrapped.valueOf(...) with Wrapped.parseWrapped(...)
where the value will be immediately unboxed anyway. The change removes small-but-pervasive inefficiencies from creating and immediately discarding instances of the wrapped value, as well as removing unnecessary syntax. More information: go/lsc-immediateunboxing Tested: tap_presubmit: http://test/OCL:189509157:BASE:189708880:1521556795490:d7b0a09a Some tests failed; test failures are believed to be unrelated to this CL ------------- Created by MOE: https://github.com/google/moe MOE_MIGRATED_REVID=189880661
1 parent cf75a23 commit 2c810d5

File tree

2 files changed

+12
-13
lines changed
  • google-http-client-android/src/main/java/com/google/api/client/extensions/android/json
  • google-http-client-gson/src/main/java/com/google/api/client/json/gson

2 files changed

+12
-13
lines changed

google-http-client-android/src/main/java/com/google/api/client/extensions/android/json/AndroidJsonParser.java

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -78,26 +78,26 @@ public JsonFactory getFactory() {
7878
@Override
7979
public byte getByteValue() {
8080
checkNumber();
81-
return Byte.valueOf(currentText);
81+
return Byte.parseByte(currentText);
8282
}
8383

8484
@Override
8585
public short getShortValue() {
8686
checkNumber();
87-
return Short.valueOf(currentText);
87+
return Short.parseShort(currentText);
8888
}
8989

9090

9191
@Override
9292
public int getIntValue() {
9393
checkNumber();
94-
return Integer.valueOf(currentText);
94+
return Integer.parseInt(currentText);
9595
}
9696

9797
@Override
9898
public float getFloatValue() {
9999
checkNumber();
100-
return Float.valueOf(currentText);
100+
return Float.parseFloat(currentText);
101101
}
102102

103103
@Override
@@ -115,13 +115,13 @@ public BigDecimal getDecimalValue() {
115115
@Override
116116
public double getDoubleValue() {
117117
checkNumber();
118-
return Double.valueOf(currentText);
118+
return Double.parseDouble(currentText);
119119
}
120120

121121
@Override
122122
public long getLongValue() {
123123
checkNumber();
124-
return Long.valueOf(currentText);
124+
return Long.parseLong(currentText);
125125
}
126126

127127
private void checkNumber() {

google-http-client-gson/src/main/java/com/google/api/client/json/gson/GsonParser.java

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@
1919
import com.google.api.client.json.JsonToken;
2020
import com.google.api.client.util.Preconditions;
2121
import com.google.gson.stream.JsonReader;
22-
2322
import java.io.EOFException;
2423
import java.io.IOException;
2524
import java.math.BigDecimal;
@@ -74,26 +73,26 @@ public JsonFactory getFactory() {
7473
@Override
7574
public byte getByteValue() {
7675
checkNumber();
77-
return Byte.valueOf(currentText);
76+
return Byte.parseByte(currentText);
7877
}
7978

8079
@Override
8180
public short getShortValue() {
8281
checkNumber();
83-
return Short.valueOf(currentText);
82+
return Short.parseShort(currentText);
8483
}
8584

8685

8786
@Override
8887
public int getIntValue() {
8988
checkNumber();
90-
return Integer.valueOf(currentText);
89+
return Integer.parseInt(currentText);
9190
}
9291

9392
@Override
9493
public float getFloatValue() {
9594
checkNumber();
96-
return Float.valueOf(currentText);
95+
return Float.parseFloat(currentText);
9796
}
9897

9998
@Override
@@ -111,13 +110,13 @@ public BigDecimal getDecimalValue() {
111110
@Override
112111
public double getDoubleValue() {
113112
checkNumber();
114-
return Double.valueOf(currentText);
113+
return Double.parseDouble(currentText);
115114
}
116115

117116
@Override
118117
public long getLongValue() {
119118
checkNumber();
120-
return Long.valueOf(currentText);
119+
return Long.parseLong(currentText);
121120
}
122121

123122
private void checkNumber() {

0 commit comments

Comments
 (0)