faster or no difference
#1

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.
Reply
#2

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.
Reply
#3

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.
Reply
#4

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

thanks, i knew that i was right
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)