Thread: [Solved] Optimized Plugin?
View Single Post
akcaliberg
Senior Member
Join Date: Nov 2011
Location: Istanbul
Old 06-13-2018 , 15:18   Re: Optimized Plugin?
Reply With Quote #5

Since a variable can only have a single value at a time, you should not keep comparing it with other values once you find a match.

So instead of doing:

PHP Code:
if(something == a) ...
if(
something == b) ...
if(
something == c) ... 
You should do:

PHP Code:
if(something == a) ...
else if(
something == b) ...
else if(
something == c) ... 
It will be even better if you use the switch statement:

PHP Code:
switch(something) {
   case 
a: {
      ...
   }
   case 
b: {
      ...
   }
   case 
c: {
      ...
   }

akcaliberg is offline