Raised This Month: $87 Target: $400
 21% 

Return an array in stock


Post New Thread Reply   
 
Thread Tools Display Modes
KiLLeR.
Senior Member
Join Date: Jul 2014
Location: Bulgaria
Old 10-18-2017 , 21:26   Re: Return an array in stock
Reply With Quote #11

Quote:
Originally Posted by HamletEagle View Post
I'm pretty sure someone(Klippy? [email protected]?) posted a good explanations about that. You should try searching.
Are you talking about that?! Also he is using a module and I was asking just for simple function in amxx plugin. As far as I understand the biggest problem is that returning array use 2x more memory?!
KiLLeR. is offline
HamletEagle
AMX Mod X Plugin Approver
Join Date: Sep 2013
Location: Romania
Old 10-19-2017 , 03:59   Re: Return an array in stock
Reply With Quote #12

Quote:
Originally Posted by KiLLeR. View Post
Are you talking about that?! Also he is using a module and I was asking just for simple function in amxx plugin. As far as I understand the biggest problem is that returning array use 2x more memory?!
No. I was telling to search about why it's bad to return arrays. Just do not do it.
__________________
HamletEagle is offline
siriusmd99
Veteran Member
Join Date: Oct 2013
Location: Republic of Moldova
Old 10-19-2017 , 09:32   Re: Return an array in stock
Reply With Quote #13

O also thought about that 2x memory logic.
When you write directly to array its just one action but when you return a value it writes the same values 2 times. Like one time in local array from function and second time when you write values in external array.

I'm think that's an enough reason not to use return..

Also I think the same thing can be said about integers values. Like instead of returning value of an expression, it can be saved directly to an external integer variable. It's more symbols in code but I think its more efficient when you call a function like per frame and it saves directly to integer variable.

I am wrong?
siriusmd99 is offline
Bugsy
AMX Mod X Moderator
Join Date: Feb 2005
Location: NJ, USA
Old 10-22-2017 , 12:14   Re: Return an array in stock
Reply With Quote #14

The amount benefit for storing directly to the external variable (byref) versus a function returning a value and then being set is trivial. Plus, you may only want to conditionally set the value to the external variable based on a particular outcome of the function. I would only set byref if it makes sense from a program-flow/programming perspective.
__________________
Bugsy is offline
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 20:57.


Powered by vBulletin®
Copyright ©2000 - 2017, vBulletin Solutions, Inc.
Theme made by Freecode