Drakath Posted August 18, 2014 Share Posted August 18, 2014 If I have one script in my resource, is it more efficient to use: local function() ? Link to comment
Castillo Posted August 18, 2014 Share Posted August 18, 2014 I don't know if it's more efficient, but it can be useful if you want two functions using the same name in two different script files within the same resource to do different things. Link to comment
Drakath Posted August 18, 2014 Author Share Posted August 18, 2014 Yeah, I know but I heard that using local makes it faster and uses less memory or something. I wonder if that's true. Link to comment
Saml1er Posted August 18, 2014 Share Posted August 18, 2014 Yeah, I know but I heard that using local makes it faster and uses less memory or something. I wonder if that's true. Yes, accessing local variables/functions is faster than global. Link to comment
ixjf Posted August 18, 2014 Share Posted August 18, 2014 Local variables (this includes functions, because they're stored in variables too - function foo () is syntatic sugar for foo = function()) are indeed faster to access because they're stored on the stack. On the other hand, to access globals you must do a hash table lookup (in the environment table). Link to comment
Drakath Posted August 19, 2014 Author Share Posted August 19, 2014 Great, I will start using local functions most of the time now. Thanks for the information. Link to comment
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now