Forum Multiplayer using variables from messages over and over again

Discussion and help relating to the PlayerIO Multiplayer API.

using variables from messages over and over again

Postby playstation3Dood » April 13th, 2010, 11:07 am

I'm using a variable from a message a few times over, and i was wondering which way to do so would be more efficient. please forgive me if this is a stupid or n00b question as I am not a pro :D .

method 1 setting an int/string/whatever to value of message.GetInt() :
Code: Select all
GotMessage(Player p, Message message){
      //do whatever
      int theInt = message.getInt(0);

      someFunction(theInt);
      someOtherFunction(theInt);
      someOtherOtherFunction(theInt);
      //etc....
}


method 2 just using message.GetInt() (too lazy to manage all the various Ints and strings and booleans etc.) :
Code: Select all

GotMessage(Player p, Message message){
      //do whatever
      someFunction(message.getInt(0));
      someOtherFunction(message.getInt(0));
      someOtherOtherFunction(message.getInt(0));     
      //etc....
}


I am currently using method 2 because, as stated, i'm lazy :lol: and dont mind typing the few extra characters. is it less efficient that method 1? does it even make a difference in either flash or c#?
playstation3Dood
 
Posts: 49
Joined: February 23rd, 2010, 7:39 am

Re: using variables from messages over and over again

Postby Benjaminsen » April 13th, 2010, 11:29 am

Using getXXX repeatedly will always be slower than storing a temporary variable. The difference should however be minimal.
Benjaminsen
.IO
 
Posts: 1444
Joined: January 12th, 2010, 11:54 am
Location: Denmark

Re: using variables from messages over and over again

Postby playstation3Dood » April 13th, 2010, 11:31 am

Ok great, thanks for clarifying Benjamin
playstation3Dood
 
Posts: 49
Joined: February 23rd, 2010, 7:39 am


Return to Multiplayer