View Single Post
04-29-16, 04:44 AM   #23
Gello
A Molten Giant
AddOn Author - Click to view addons
Join Date: Jan 2005
Posts: 521
That would create an extreme amount of garbage due to the temporary tables. And it makes a compelling case for them to pass the numerical spellID in that last parameter if it's truly random/unused. String manipulation can create excessive garbage if not done with a little care.

In a test of 1000 random GUIDs run through 100 times (for 100k parses):

Code:
return tonumber((select(5, strsplit("-", GUID))))
Took 118ms and created 80k of garbage.

Code:
local x = { strsplit("-", GUID) }
return tonumber(x[5])
Took 247ms and created 8335k of garbage.

Code:
local _,_,_,_,x = strsplit("-",GUID)
return tonumber(x)
Took 110ms and created 80k of garbage.

Code:
local x = GUID:match("(%d+)%-(%x+)$")
return tonumber(x)
Took 380ms and created 80k of garbage.

Code:
local x = GUID:match("^%d+%-%d+%-%d+%-%d+%-(%d+)")
return tonumber(x)
Took 127ms and created 38k of garbage.

Code:
local x = GUID:match("%d+%-%d+%-%d+%-%d+%-(%d+)%-%x+")
return tonumber(x)
Took 147ms and created 38k of garbage.

Unfortunately I can't post the testing code since these forums are throwing a CloudFlare blocked page when attempting to do so.