You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Function stdnse.fromhex() is used extensively throughout the NSE codebase, which makes it worth optimizing. The following drop-in replacement performs about 43% faster[1] and creates only a quarter of temporary Lua strings than the current implementation:
functionfromhex (hex)
localp=hex:find("[^%x%s]")
ifpthenreturnnil, "Invalid hexadecimal digits at position " ..pendhex=hex:gsub("%s+", "")
if#hex%2~=0thenreturnnil, "Odd number of hexadecimal digits"endreturnhex:gsub("..", function (h) returnstring.char(tonumber(h, 16)) end)
end
I will commit the change in a few weeks unless concerns are raised.
Function
stdnse.fromhex()
is used extensively throughout the NSE codebase, which makes it worth optimizing. The following drop-in replacement performs about 43% faster[1] and creates only a quarter of temporary Lua strings than the current implementation:I will commit the change in a few weeks unless concerns are raised.
[1] https://gist.github.com/nnposter/b9e4e1a9b9d2637f8c8c6b2948866640
The text was updated successfully, but these errors were encountered: