What is more optimized?
#1

If we have anything like this:

1st option:
Код:
if(blablabla) RemovePlayerFromVehicle(playerid), SendClientMessage(playerid, WHITE, "You dont have keys!");
2nd option:
Код:
if(blablabla) 
{
RemovePlayerFromVehicle(playerid);
SendClientMessage(playerid, WHITE, "You dont have keys!");
}
3rd option:
Код:
if( blablabla )  {
RemovePlayerFromVehicle( playerid );
SendClientMessage(playerid, WHITE, "You dont have keys!");
}
Which option is better?
Reply
#2

I would say none, it is three times the same code just written differently
Reply
#3

This isnt an optimization question, its a code readability one.

The middle, except with a tab starting each line between the { } brackets

Код:
if(blablabla) 
{
     RemovePlayerFromVehicle(playerid);
     SendClientMessage(playerid, WHITE, "You dont have keys!");
}
Reply
#4

Ok if you want to get technical...

Number 1 is the most efficient here. Both the braces and the second ';' add "break"'s to the assembly.

However, both numbers 2 and 3 are more formal.

I address these in the Tiny Optimizations thread: https://sampforum.blast.hk/showthread.php?tid=606026

The speed difference that the breaks bring to the assembly are very negligible though. The major speed differences here are the functions themselves. You really don't need to worry about this, just do what fits your style best.
Reply
#5

I like the pretty printing one though.
Reply
#6

You can also do this for further readability(in reference to option #1):
pawn Код:
if(blablabla)
      RemovePlayerFromVehicle(playerid), SendClientMessage(playerid, WHITE, "You dont have keys!");
Reply
#7

Quote:
Originally Posted by [ND]xXZeusXx.
Посмотреть сообщение
I like the pretty printing one though.
wtf go away
Reply
#8

I prefer option 3 with indentation.
Reply
#9

Thank you all
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)