mirror of
https://github.com/nmap/nmap.git
synced 2025-12-20 14:39:02 +00:00
More string.sub vs. string.byte optimizations
This commit is contained in:
@@ -1718,13 +1718,8 @@ PreLoginPacket =
|
|||||||
end
|
end
|
||||||
|
|
||||||
if ( optionType == PreLoginPacket.OPTION_TYPE.Version ) then
|
if ( optionType == PreLoginPacket.OPTION_TYPE.Version ) then
|
||||||
local major, minor, build, subBuild, version
|
local major, minor, build, subBuild = (">BBI2I2"):unpack(optionData)
|
||||||
major = string.byte( optionData:sub( 1, 1 ) )
|
local version = SqlServerVersionInfo:new()
|
||||||
minor = string.byte( optionData:sub( 2, 2 ) )
|
|
||||||
build = (string.byte( optionData:sub( 3, 3 ) ) * 256) + string.byte( optionData:sub( 4, 4 ) )
|
|
||||||
subBuild = (string.byte( optionData:sub( 5, 5 ) ) * 256) + string.byte( optionData:sub( 6, 6 ) )
|
|
||||||
|
|
||||||
version = SqlServerVersionInfo:new()
|
|
||||||
version:SetVersion( major, minor, build, subBuild, "SSNetLib" )
|
version:SetVersion( major, minor, build, subBuild, "SSNetLib" )
|
||||||
preLoginPacket.versionInfo = version
|
preLoginPacket.versionInfo = version
|
||||||
elseif ( optionType == PreLoginPacket.OPTION_TYPE.Encryption ) then
|
elseif ( optionType == PreLoginPacket.OPTION_TYPE.Encryption ) then
|
||||||
|
|||||||
@@ -3482,7 +3482,7 @@ function get_uniqueish_name(host, extension, seed)
|
|||||||
local str = lhost .. (seed or "") .. (extension or "") .. (nmap.registry.args.randomseed or "")
|
local str = lhost .. (seed or "") .. (extension or "") .. (nmap.registry.args.randomseed or "")
|
||||||
|
|
||||||
for i = 1, #str, 1 do
|
for i = 1, #str, 1 do
|
||||||
local chr = string.byte(string.sub(str, i, i), 1)
|
local chr = str:byte(i)
|
||||||
hash = bit.bxor(hash, chr)
|
hash = bit.bxor(hash, chr)
|
||||||
hash = bit.bor(bit.lshift(hash, 3), bit.rshift(hash, 29))
|
hash = bit.bor(bit.lshift(hash, 3), bit.rshift(hash, 29))
|
||||||
hash = bit.bxor(hash, 3)
|
hash = bit.bxor(hash, 3)
|
||||||
|
|||||||
@@ -87,7 +87,7 @@ local function screen_diff( orig_screen, current_screen )
|
|||||||
if #orig_screen == 0 or #current_screen == 0 then return 0 end
|
if #orig_screen == 0 or #current_screen == 0 then return 0 end
|
||||||
local m = 1
|
local m = 1
|
||||||
for i =1 , #orig_screen do
|
for i =1 , #orig_screen do
|
||||||
if orig_screen:sub(i,i) == current_screen:sub(i,i) then
|
if orig_screen:byte(i) == current_screen:byte(i) then
|
||||||
m = m + 1
|
m = m + 1
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
Reference in New Issue
Block a user