Update scripted_ents.lua #877

Merged
merged 1 commit into from Mar 26, 2015

Projects

None yet

5 participants

@NeatNit
Contributor
NeatNit commented Feb 23, 2015

Why on earth would you call Get twice here?

@NeatNit NeatNit Update scripted_ents.lua
Why on earth would you call Get twice here?
30b29ee
@willox
Collaborator
willox commented Feb 23, 2015

I'm happy to acknowledge that when my scripts load they will be free of a few unnecessary operations.

@NeatNit
Contributor
NeatNit commented Feb 23, 2015

That sounds like sarcasm ಠ_ಠ

While I agree that this change is very minor - you don't know how people might be using this function. If you have a sent based on a sent based on a sent, You'll be calling Get 7 times instead of 3.

Edit: and besides, it's small things like this that add up, and sometimes you want your loading times to be faster. Notice how in sandbox the Q menu could take several seconds to open the first time you open it? It's in part because of this kind of nonsense.

Not that I care all that much :P

@willox
Collaborator
willox commented Feb 23, 2015

That still wouldn't be an issue. It's not a bad change, though. I'm all for good code.

@comedinha comedinha commented on the diff Feb 23, 2015
garrysmod/lua/includes/modules/scripted_ents.lua
@@ -149,14 +149,16 @@ function Get( name )
-- Derive from base class
if ( name != SEntList[ name ].Base ) then
@comedinha
comedinha Feb 23, 2015 Contributor

SEntList[ name ].Base

@willox
willox Feb 23, 2015 Collaborator

If you're suggesting the if statement here isn't neccesary, I assume it's so that we don't get any infinite loops on base_entity (which is its own base as all entities must have a base).

@TheFreeman193
Contributor

I'm surprised, but this actually seems to be about 32-35% quicker.

@robotboy655 robotboy655 merged commit dfed401 into garrynewman:master Mar 26, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment