core/vm: optimize CLZ

This commit is contained in:
Felix Lange 2025-07-07 11:01:41 +02:00
parent 81546c64c7
commit 166ad3efe1

View file

@ -294,10 +294,10 @@ func opBlobBaseFee(pc *uint64, interpreter *EVMInterpreter, scope *ScopeContext)
return nil, nil return nil, nil
} }
// opCLZ implements the CLZ opcode (count leading zero bytes)
func opCLZ(pc *uint64, interpreter *EVMInterpreter, scope *ScopeContext) ([]byte, error) { func opCLZ(pc *uint64, interpreter *EVMInterpreter, scope *ScopeContext) ([]byte, error) {
x := scope.Stack.pop() x := scope.Stack.peek()
// count leading zero bits in x x.SetUint64(256 - uint64(x.BitLen()))
scope.Stack.push(new(uint256.Int).SetUint64(256 - uint64(x.BitLen())))
return nil, nil return nil, nil
} }