From 65d4e1817a10c242b99425341785a9eb1414d779 Mon Sep 17 00:00:00 2001 From: Mark Hansen Date: Wed, 17 Jul 2024 10:07:38 -0700 Subject: [PATCH] Micro-optimisation: remove no-op body of hot GeneratedMessage.Builder constructor We are seeing in profiles that this constructor is calling the other constructor. It doesn't seem to be totally inlined, as the times spent in each constructor stack frame are different. In the common case of no builderParent, the constructor can be empty. PiperOrigin-RevId: 653272368 --- .../src/main/java/com/google/protobuf/GeneratedMessage.java | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/java/core/src/main/java/com/google/protobuf/GeneratedMessage.java b/java/core/src/main/java/com/google/protobuf/GeneratedMessage.java index aeeeb94e3d..e8a7cc8f97 100644 --- a/java/core/src/main/java/com/google/protobuf/GeneratedMessage.java +++ b/java/core/src/main/java/com/google/protobuf/GeneratedMessage.java @@ -489,9 +489,7 @@ public abstract class GeneratedMessage extends AbstractMessage implements Serial */ private Object unknownFieldsOrBuilder = UnknownFieldSet.getDefaultInstance(); - protected Builder() { - this(null); - } + protected Builder() {} protected Builder(BuilderParent builderParent) { this.builderParent = builderParent;