mirror of
https://github.com/nmap/nmap.git
synced 2026-08-03 22:29:06 +00:00
Localize a few functions in stdnse.generate_random_string for performance reasons
This commit is contained in:
parent
d0b360b1a2
commit
25725d369e
1 changed files with 5 additions and 3 deletions
|
|
@ -30,10 +30,12 @@ local type = type
|
|||
|
||||
local ceil = math.ceil
|
||||
local max = math.max
|
||||
local random = math.random
|
||||
|
||||
local format = string.format;
|
||||
local rep = string.rep
|
||||
local match = string.match
|
||||
local char = string.char
|
||||
|
||||
local concat = table.concat;
|
||||
local insert = table.insert;
|
||||
|
|
@ -246,14 +248,14 @@ function generate_random_string(len, charset)
|
|||
local ascii_Z = 90
|
||||
if charset then
|
||||
for i=1,len do
|
||||
t[i]=charset[math.random(#charset)]
|
||||
t[i]=charset[random(#charset)]
|
||||
end
|
||||
else
|
||||
for i=1,len do
|
||||
t[i]=string.char(math.random(ascii_A,ascii_Z))
|
||||
t[i]=char(random(ascii_A,ascii_Z))
|
||||
end
|
||||
end
|
||||
return table.concat(t)
|
||||
return concat(t)
|
||||
end
|
||||
|
||||
--- Return a wrapper closure around a socket that buffers socket reads into
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue