![]() |
#1 |
User
Join Date: Aug 2003
Posts: 104
![]() |
![]() I want my map to be as efficient as possible in the basic code (not worrying about systems here, just plain Jass). I've searched around for tips on this but am not completely sure what the pros/cons are of the following snippets of code. Would someone mind pointing out the pros/cons of each of the following in terms of efficiency? Thanks.
Method A ![]() set udg_MyUnitArray[94] = GetTriggerUnit() call PauseUnit(udg_MyUnitArray[94], true) call IssueImmediateOrder(udg_MyUnitArray[94], "stop") call PauseUnit(udg_MyUnitArray[iDynamic], false) Method B ![]() local unit uTemp = GetTriggerUnit() set udg_MyUnitArray[94] = uTemp call PauseUnit(uTemp, true) call IssueImmediateOrder(uTemp, "stop") call PauseUnit(uTemp, false) set uTemp = null Method C ![]() set udg_MyUnitArray[94] = GetTriggerUnit() call PauseUnit(GetTriggerUnit(), true) call IssueImmediateOrder(GetTriggerUnit(), "stop") call PauseUnit(GetTriggerUnit(), false) Last edited by marshall : 08-24-2009 at 06:30 PM. |
![]() |
![]() |
Sponsored Links - Login to hide this ad! |
|
![]() |
#2 |
User
Join Date: Jul 2009
Posts: 22
![]() |
![]() ![]() call PauseUnit(GetTriggerUnit(), true) call IssueImmediateOrder(GetTriggerUnit(), "stop") call PauseUnit(GetTriggerUnit(), false) |
![]() |
![]() |
![]() |
#3 |
Obscurity, the Art
|
![]() Method B results in the cleanest code, and the speed differences between A, B, and C are negligible. Thus I would recommend using method B.
__________________![]() function MyFunc takes nothing returns nothing local unit u = GetTriggerUnit() call PauseUnit(u, true) call IssueImmediateOrder(u, "stop") call PauseUnit(u, false) set u = null endfunction |
![]() |
![]() |
![]() |
#4 |
It feels good
Join Date: Mar 2006
Posts: 1,305
![]() ![]() ![]() |
![]() method A has to do an array lookup. method B consumes an extra vraible. and method c has to make loads of function calls. the least of the evils is method b.
__________________ |
![]() |
![]() |
![]() |
#5 |
User
Join Date: Aug 2003
Posts: 104
![]() |
![]() Thanks guys that's most helpful. I didn't mention that I need the array elsewhere so, given that I have to have the array set anyway, would that make A better than B?
Last edited by marshall : 08-24-2009 at 06:40 PM. |
![]() |
![]() |
![]() |
#6 |
Zerzy
|
![]() Not really, B is still better because of organization while A requires array lookup. I think everyone already factored in the need to set the unit as part of the array ;)
__________________Last edited by Zerzax : 08-24-2009 at 11:49 PM. |
![]() |
![]() |
![]() |
#7 | |
Two Blue
|
![]() Quote:
The difference between A and B would amount to the difference in the weight of two coins of the same denomination selected at random. The secret to truly fast JASS code: reduce function calls to a minimum. The only places where Truly Fast JASS™ will make any kind of noticeable difference will be in iterative or recursive shit which recurses/iterates a large number of times. Trying to optimize a function that's called maybe once every 5 seconds will sooner drive you insane then it will actually make any kind of measurable difference. |
|
![]() |
![]() |
![]() |
#8 |
Procrastination Incarnate
Development Director
|
![]() This thread is so 2006.
__________________Like people have already pointed out, the speed difference between the methods is absurdly small, practically nonexistant, so in this case readability definitely trumps efficiency. |
![]() |
![]() |
![]() |
#9 |
User
Join Date: Aug 2003
Posts: 104
![]() |
![]() Thank you all, really cleared things up for me :)
And apologies if this was already well known stuff! |
![]() |
![]() |
![]() |
#10 | |
Procrastination Incarnate
Development Director
|
![]() Quote:
|
|
![]() |
![]() |
![]() |
Thread Tools | Search this Thread |
|
|