wiremod / wire

Garry's Mod add-on that allows users to wire up components in order to make more elaborate automatic and user-controlled contraptions.
http://www.wiremod.com
Apache License 2.0
549 stars 333 forks source link

Reduce index calls on EGP:ValidEGP #2962

Closed brandonsturgeon closed 8 months ago

brandonsturgeon commented 8 months ago

Simple optimization to reduce entity __index calls for this commonly-used method. With only a few EGPs out, I recorded 77,762 __index calls from this method over a 10 second sample.

Also, from a high-level skim, it seems like this could even be cached on the EGP entity itself to make it even faster.

Vurv78 commented 8 months ago

If indexing is a problem, couldn't you take the functions from the metatable directly and just use those?

brandonsturgeon commented 8 months ago

I'd like to fix the linting issues in this file. I could do it in this PR while I'm here, or I could do it in a followup PR - up to you 👍

Denneisk commented 8 months ago

GetVar uses GetTable internally and has overhead for a default value so I would prefer just using GetTable.