On Wed, 28 Aug 2024 10:26:58 GMT, Shaojin Wen <d...@openjdk.org> wrote:
> Small improvement, add a final field, no need to calculate every time. Of course, the implementation complexity of these two is different, and the code size is also different. ## codeSize # baseline java.lang.classfile.TypeKind::slotSize (50 bytes) # current java.lang.classfile.TypeKind::slotSize (5 bytes) inline ## bytecode * baseline public int slotSize(); Code: 0: aload_0 1: invokevirtual #60 // Method ordinal:()I 4: lookupswitch { // 3 4: 44 5: 44 9: 40 default: 48 } 40: iconst_0 41: goto 49 44: iconst_2 45: goto 49 48: iconst_1 49: ireturn * current public int slotSize(); Code: 0: aload_0 1: getfield #60 // Field slotSize:I 4: ireturn This is not a high frequency call, a slight improvement ------------- PR Comment: https://git.openjdk.org/jdk/pull/20743#issuecomment-2315182651