Code Speed: Functions

NoobImbaPro

You can change this now in User CP.
Reaction score
60
They have same speed or second is faster?

JASS:
.
    function A takes nothing returns nothing
        //a bunch of lines
    endfunction

    function B takes nothing returns nothing
        if condition then
            call A()
        endif
    endfunction


JASS:
.
    function B takes nothing returns nothing
        if condition then
            //lines of function A
        endif
    endfunction
 

tooltiperror

Super Moderator
Reaction score
231
This is (usually) even better, though:
JASS:
function B takes nothing returns nothing
    if not condition then
        return
    endif
    // lines of function A
endfunction

This way you can skip the rest of the function (like searching for the [ljass]endif[/ljass].)
 

Bribe

vJass errors are legion
Reaction score
67
Only if function A was only one line of code. Otherwise it wouldn't (couldn't).
 

WaterKnight

Member
Reaction score
7
Functions without parameters cost nearly nothing. Else it has to declare the locals and assign them the incoming values. But it's nuts to make this priority. There are other interests mapmakers strive for like progress, modularity, not write the same things twice, build greater structures. Would only do this if it was really necessary in the standalone low-level.
 

Bribe

vJass errors are legion
Reaction score
67
I use functions to avoid duplicate text whenever possible. I also recommend to anyone else to do the same.
 
General chit-chat
Help Users
  • No one is chatting at the moment.

      The Helper Discord

      Members online

      No members online now.

      Affiliates

      Hive Workshop NUON Dome World Editor Tutorials

      Network Sponsors

      Apex Steel Pipe - Buys and sells Steel Pipe.
      Top