garrysmod-requests
garrysmod-requests copied to clipboard
Implement optimization for `CCvar::FindCommandBase`
Details
Implementation: https://github.com/Source-Authors/Obsoletium/compare/master...RaphaelIT7:obsolete-source-engine:patch-8
I made this optimization a while ago & implemented it into holylib which showed up to a ~40x(normally around ~10x) performance improvement in my cases without causing any issues.
The current implementation has the issue that it becomes slower with each added convar which is solved with this change.
FindCommandBase isn't a huge function and is not called frequently, so it won't really be noticeable, but for calls like GetConVar_Internal it will definitely be a noticeable improvement.
Just to mention it, it seems like CS:GO does already have something like this.
Maybe the 64x of Gmod also already has this & only 32x is missing it?
-> https://github.com/perilouswithadollarsign/cstrike15_src/blob/master/vstdlib/cvar.cpp#L615-L632
CS:GO uses CConCommandHash m_CommandHash which probably works the same way, if not possibly even better than the method I had implemented.
~~I do think that this will break binary modules though, by removing GetCommands methods from ICvar.~~
Nevermind, VPhysics relies on those, so we got to keep it.