garrysmod
garrysmod copied to clipboard
TypeID and is* functions in Lua
This now should fully close https://github.com/Facepunch/garrysmod-issues/issues/4100
The only difference in behaviour is that old one (probably) doesn't use the MetaID of a userdata if it's not a gmod type? Not sure really.
Both new functions need to be placed after the new type function to work correctly.
I forgot to localize getmetatable for type function, wanted to see if it's going to make a difference, and saw around 10~15% increase in performance when benchmarking my serializing library. (basically place local getmetatable = getmetatable before this and type function)
You can make the is* functions a fair bit faster by doing something similar to this.
Whether it's really worth it 🤷
You can make the is* functions a fair bit faster by doing something similar to this.
Whether it's really worth it 🤷
I think you missed that we already getting the default type function which is the fastest you can get lol (it's already there for server/menu states on x64) https://github.com/Facepunch/garrysmod/pull/2201
I will apply a micro-optimization to make it use the Ctype function for builtin types
Your Lua implementation of isentity will not work for all entities. Subclasses like Weapon and Vehicle have their own metatable and MetaName, so type will return Weapon or Vehicle for them
Nice catch, will push a fix, also forgot that IsEntity exists too lul
I think function isbool( v ) return v == true or v == false end will be even faster
I think
function isbool( v ) return v == true or v == false endwill be even faster
Your right indeed, although I don't think the performance difference will matter that much but no reason to deny it 🥸
I think
function isbool( v ) return v == true or v == false endwill be even fasterYour right indeed, although I don't think the performance difference will matter that much but no reason to deny it 🥸
So why not do this to get at least a little extra speed
I think
function isbool( v ) return v == true or v == false endwill be even fasterYour right indeed, although I don't think the performance difference will matter that much but no reason to deny it 🥸
So why not do this to get at least a little extra speed
I thought I updated it, thanks for reminding me lol
After testing this for 1 minute - it causes regression in the killfeed:
Probably elsewhere too.
After testing this for 1 minute - it causes regression in the killfeed:
Probably elsewhere too.
It's because you forgot to push the builtin type function clientside, told you about it on discord but just to make sure you don't forget about it:
:(
bump
