wc3campaigns
WC3C Homepage - www.wc3c.netUser Control Panel (Requires Log-In)Engage in discussions with other users and join contests in the WC3C forums!Read one of our many tutorials, ranging in difficulty from beginner to advanced!Show off your artistic talents in the WC3C Gallery!Download quality models, textures, spells (vJASS/JASS), systems, and scripts!Download maps that have passed through our rigorous approval process!

Go Back   Wc3C.net > Warcraft III Modding > Developer's Corner > Triggers & Scripts
User Name
Password
Register Rules Get Hosted! Chat Pastebin FAQ and Rules Members List Calendar



Reply
 
Thread Tools Search this Thread
Old 02-27-2014, 10:37 PM   #1
Fledermaus
default string
 
Fledermaus's Avatar
 
Join Date: May 2006
Posts: 637

Submissions (1)

Fledermaus has a spectacular aura about (148)

Send a message via MSN to Fledermaus
Default Local variables V GetTriggerUnit()

At what point does it become better (read: faster) to use a local variable to store an event variable rather than using the function call?

e.g.
Expand JASS:
or
Expand JASS:

Is it after you would use the function X times or does it depend on other stuff?
I know the first is less function calls but is that outweighed by having to create and null a local variable?

Last edited by Fledermaus : 02-27-2014 at 10:39 PM.
Fledermaus is offline   Reply With Quote
Sponsored Links - Login to hide this ad!
Old 02-28-2014, 06:35 AM   #2
DioD
obey
 
DioD's Avatar
 
Join Date: Feb 2006
Posts: 1,532

Submissions (4)

DioD is a jewel in the rough (220)DioD is a jewel in the rough (220)DioD is a jewel in the rough (220)DioD is a jewel in the rough (220)

Send a message via ICQ to DioD
Default

benchmark it.
DioD is offline   Reply With Quote
Old 02-28-2014, 07:32 AM   #3
PurgeandFire111
User
 
PurgeandFire111's Avatar
 
Join Date: Dec 2006
Posts: 251

PurgeandFire111 will become famous soon enough (58)PurgeandFire111 will become famous soon enough (58)

Default

Last time I benched it, it was 2 times. Local declaration is fast, and so is nulling it. So usually I'll call the same function within a function 2 times at most. iirc, the difference between something like this was pretty negligble:
Collapse JASS:
call BJDebugMsg(GetUnitName(GetTriggerUnit()) + GetUnitName(GetTriggerUnit()))

// ... vs ...

local unit u = GetTriggerUnit()
call BJDebugMsg(GetUnitName(u) + GetUnitName(u))
set u = null

(that code is just an example, not the actual code I used). I don't remember which one is necessarily faster. When you have 3 function calls vs. a local declaration, I'm 90% certain that the local declaration was the faster option.

... But all this is just from my memory, which can be foggy. Sadly, I can't test it (yay Macs).
PurgeandFire111 is offline   Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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

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


All times are GMT. The time now is 11:09 AM.


Donate

Affiliates
The Hubb http://bylur.com - Warcraft, StarCraft, Diablo and DotA Blog & Forums The JASS Vault Clan WEnW Campaign Creations Clan CBS GamesModding Flixreel Videos

Powered by vBulletin (Copyright ©2000 - 2014, Jelsoft Enterprises Ltd).
Hosted by www.OICcam.com
IT Support and Services provided by Executive IT Services