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
}
// opCLZ implements the CLZ opcode (count leading zero bytes)
func opCLZ(pc *uint64, interpreter *EVMInterpreter, scope *ScopeContext) ([]byte, error) {
x := scope.Stack.pop()
// count leading zero bits in x
scope.Stack.push(new(uint256.Int).SetUint64(256 - uint64(x.BitLen())))
x := scope.Stack.peek()
x.SetUint64(256 - uint64(x.BitLen()))
return nil, nil
}