garrysmod
garrysmod copied to clipboard
A few string lib optimizations
Didn't know string.gsub was faster than str:gsub
yeah can we see some benchmarks on that?
yeah can we see some benchmarks on that?
It's intuitive. str:x will call __index then the method as opposed to str.x which accesses the method directly (though both do string table lookups every time as opposed to localising which is even more efficient). You can see this difference clearly in the output bytecode, even with JIT. It's too few cycles for benchmarks to be as useful of a tool in measuring gain, but I'm sure at enough indexes it will become noticeable enough.
These changes are all included in https://github.com/Facepunch/garrysmod/pull/1407 too.
@Kefta only thing missing is the regex updates here. I have them in starfall at least until whenever devs decide to accept PR code
I have undone some problematic changes (https://github.com/Facepunch/garrysmod/pull/1812/commits/32810d5b9ad694406fcb15f0e1e759eb001c8090)