Avoid unboxing boxed primitives that we're just going to re-box back up to call compareTo with.

This may save some alloactions if java's intrinsics aren't smart enough to avoid the roundtrip. But most JVMs probably have smart enough intrinsics, so this is probably not going to speed things up, just make the code look nicer.

PiperOrigin-RevId: 653445330
pull/17459/head
Mark Hansen 4 months ago committed by Copybara-Service
parent 5b45a65567
commit cb323f4359
  1. 6
      java/core/src/main/java/com/google/protobuf/TextFormat.java

@ -449,11 +449,11 @@ public final class TextFormat {
}
switch (fieldType) {
case BOOLEAN:
return Boolean.valueOf((boolean) getKey()).compareTo((boolean) b.getKey());
return ((Boolean) getKey()).compareTo((Boolean) b.getKey());
case LONG:
return Long.valueOf((long) getKey()).compareTo((long) b.getKey());
return ((Long) getKey()).compareTo((Long) b.getKey());
case INT:
return Integer.valueOf((int) getKey()).compareTo((int) b.getKey());
return ((Integer) getKey()).compareTo((Integer) b.getKey());
case STRING:
String aString = (String) getKey();
String bString = (String) b.getKey();

Loading…
Cancel
Save