diff --git a/java/core/src/main/java/com/google/protobuf/CodedOutputStream.java b/java/core/src/main/java/com/google/protobuf/CodedOutputStream.java index fccdb2178e..683f3106fc 100644 --- a/java/core/src/main/java/com/google/protobuf/CodedOutputStream.java +++ b/java/core/src/main/java/com/google/protobuf/CodedOutputStream.java @@ -2266,7 +2266,10 @@ public abstract class CodedOutputStream extends ByteOutput { * responsibility of the caller. */ final void buffer(byte value) { - buffer[position++] = value; + int position = this.position; + buffer[position] = value; + // Android optimisation: 1 fewer instruction codegen vs buffer[position++]. + this.position = position + 1; totalBytesWritten++; }