convert_square_root_call
unreleased
This rule converts calls to math.sqrt(value)
into the equivalent expression value ^ 0.5
. This transformation can be useful in some Lua runtime as a performance optimization.
Examples
local result = math.sqrt(16)
local result = 16^0.5
local result = math.sqrt(x + y)
local result = (x + y)^0.5
local result = math.sqrt(calculate_value())
local result = calculate_value()^0.5
Input | Output |
---|---|
|
|
|
|
|
|