SA-MP Forums Archive
faster or no difference - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: faster or no difference (/showthread.php?tid=336542)



faster or no difference - Blunt P - 22.04.2012

I got a Question.

some people told me that it would be faster if you script like this:
PHP код:
if(IsPlayerConnected(playerid)){SendClientMessage(playerid,COLOR_RED"Textmessage");return 1;} 
than this:

PHP код:
if(IsPlayerConnected(playerid))
{
    
SendClientMessage(playerid,COLOR_RED"Textmessage");
    return 
1;

So far i always thought, that the compiler would always optimize stuff like that, so it shouldnt make any difference.


Re: faster or no difference - Kenoja - 22.04.2012

I would just do..

if(IsPlayerConnected(playerid)) return SendClientMessage(playerid, COLOR_RED, "Textmessage");

However, programming languages don't register blank spaces. What you have is the same thing and it will run the same way.


Re: faster or no difference - Cameltoe - 22.04.2012

Quote:
Originally Posted by Blunt P
Посмотреть сообщение
I got a Question.

some people told me that it would be faster if you script like this:
PHP код:
if(IsPlayerConnected(playerid)){SendClientMessage(playerid,COLOR_RED"Textmessage");return 1;} 
than this:

PHP код:
if(IsPlayerConnected(playerid))
{
    
SendClientMessage(playerid,COLOR_RED"Textmessage");
    return 
1;

So far i always thought, that the compiler would always optimize stuff like that, so it shouldnt make any difference.
Yess well, it will probably be faster scripting like that, but the code won't execute any faster what-so-ever. The compiler reads the script and compiles it into server readable code.


Re: faster or no difference - BleverCastard - 22.04.2012

This:
Код:
if(IsPlayerConnected(playerid)) 
{ 
    SendClientMessage(playerid,COLOR_RED, "Textmessage"); 
    return 1; 
}
I would say is more tidier and easier to read.


AW: faster or no difference - Blunt P - 22.04.2012

thanks, i knew that i was right