More animation optimzation - using booleans to check IsPlaying()

Hello- first of all this is not premature optimzaion - My code is functioning as intended and my game is meant for mobile devices so I’m taking all steps I can to increase performance. I don’t have unity Pro but I will buying it once I generate some revenue.

Animation can be expensive to call every frame (I use InvokeRepeating so every frame to me is not every frame - just using Update() as example) though I have conditions which need to be checked every frame to see if any changes to animations need to be made.

Now in an attempt to optimize code I have a question about whether using a custom boolean is faster than than using the animation.IsPlaying() function.

Here are two examples below of what the code could look like

var anim : Animation; // cache transform.animation
var walkAnim: String; // cache the sting "walk"


function Update(){

/////////stuff/////

if(canMove){

     //movement code goes here

      if(!anim.IsPlaying(walkAnim)){//if the attack
                                   //animation isn't playing

          anim.Play(walkAnim);  // play the attack     
                                 //animation 


      }

}


}

VERSUS

var anim : Animation; // cache transform.animation
var walkAnim: String; // cache the sting "walk"

var walkAnimIsPlaying : boolean; // game changer right here

function Update(){

/////////stuff/////

if(canMove){

     //movement code goes here

      if(!walkAnimationIsPlaying){//if the attack
                                   //animation isn't playing boolean version

          anim.Play(walkAnim);  // play the attack     
                                //animation 

          walkAnimationIsPlaying = true;//set to stop 
                                       //calling more once
      }

}


}

As a final note this is for looping walk cycles and such. So I figured Unity loops them regardless until you tell it to Stop() or Play() something else on the same animation layer. My main concern is IsPlaying() is calling a function while boolean is defined in the current script.

if(boolean) or if(animation.IsPlaying()) - which is faster?

if(boolean) or if(animation.IsPlaying()) - which is faster?

There will not be any measurable difference.