Optimization question

Discussion in 'Plugin Development' started by BorisTheTerrible, Nov 30, 2013.

Thread Status:
Not open for further replies.
  1. I have a event that will run a lot and I was wondering?
    Would it would be better to create a local variable every time the event is run or just store data into a global variable.
     
  2. Offline

    The_Doctor_123

    Ehhh.. probably doesn't matter efficiency-wise. Local variables would make sense for readability, though.
     
  3. Offline

    Darq

    Local variables are preferred. As The_Doctor_123 said, one reason is readability. Another is that, when the code block of the event is finished running, the variable is destroyed; when using a global variable you must either null it or you will be holding onto unnecessary objects.
     
Thread Status:
Not open for further replies.

Share This Page