<commit_before>package instructions

import (
	"github.com/zxh0/jvm.go/jvmgo/jvm/rtda"
	rtc "github.com/zxh0/jvm.go/jvmgo/jvm/rtda/class"
)

// Create new object
type new_ struct{ Index16Instruction }

func (self *new_) Execute(frame *rtda.Frame) {
	cp := frame.ConstantPool()
	kClass := cp.GetConstant(self.index).(*rtc.ConstantClass)
	class := kClass.Class()

	if class.InitializationNotStarted() {
		frame.RevertNextPC() // undo new
		frame.Thread().InitClass(class)
	} else {
		ref := class.NewObj()
		frame.OperandStack().PushRef(ref)
	}
}<commit_msg>code optimization<commit_after>package instructions

import (
	"github.com/zxh0/jvm.go/jvmgo/jvm/rtda"
	rtc "github.com/zxh0/jvm.go/jvmgo/jvm/rtda/class"
)

// Create new object
type new_ struct {
	Index16Instruction
	class *rtc.Class
}

func (self *new_) Execute(frame *rtda.Frame) {
	if self.class == nil {
		cp := frame.ConstantPool()
		kClass := cp.GetConstant(self.index).(*rtc.ConstantClass)
		self.class = kClass.Class()
	}

	// init class
	if self.class.InitializationNotStarted() {
		frame.RevertNextPC() // undo new
		frame.Thread().InitClass(self.class)
		return
	}

	ref := self.class.NewObj()
	frame.OperandStack().PushRef(ref)
}
{'fraction_non_alphanumeric': 0.15358931552587646, 'fraction_numerical': 0.00667779632721202, 'mean_word_length': 4.21304347826087, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5911533', 'n_tokens_mistral': 478, 'n_tokens_neox': 463, 'n_words': 76}