Skip to content

Commit

Permalink
Improve generated ASM a little bit
Browse files Browse the repository at this point in the history
  • Loading branch information
Pyrofab committed Jul 22, 2021
1 parent 09236e5 commit a5e846f
Showing 1 changed file with 3 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -210,16 +210,16 @@ public static <I> Class<? extends ComponentContainer> spinComponentContainer(Cla

String factoryFieldDescriptor = Type.getDescriptor(componentFactoryType);

classNode.visitField(Opcodes.ACC_PRIVATE | Opcodes.ACC_STATIC, "componentKeys", "Ljava/util/Set;", null, null);
classNode.visitField(Opcodes.ACC_PRIVATE | Opcodes.ACC_STATIC, "componentKeys", "Ljava/util/Set;", "Ljava/util/Set<Ldev/onyxstudios/cca/api/v3/component/ComponentKey<*>;>;", null);

MethodVisitor keys = classNode.visitMethod(Opcodes.ACC_PUBLIC, "keys", "()Ljava/util/Set;", null, null);
MethodVisitor keys = classNode.visitMethod(Opcodes.ACC_PUBLIC, "keys", "()Ljava/util/Set;", "()Ljava/util/Set<Ldev/onyxstudios/cca/api/v3/component/ComponentKey<*>;>;", null);
keys.visitFieldInsn(Opcodes.GETSTATIC, containerImplName, "componentKeys", "Ljava/util/Set;");
keys.visitInsn(Opcodes.ARETURN);
keys.visitEnd();

MethodVisitor hasComponents = classNode.visitMethod(Opcodes.ACC_PUBLIC, "hasComponents", "()Z", null, null);
hasComponents.visitCode();
hasComponents.visitLdcInsn(!sorted.isEmpty());
hasComponents.visitInsn(sorted.isEmpty() ? Opcodes.ICONST_0 : Opcodes.ICONST_1);
hasComponents.visitInsn(Opcodes.IRETURN);
hasComponents.visitEnd();

Expand Down

0 comments on commit a5e846f

Please sign in to comment.