Tiny But Super Optimizations
#5

PHP Code:
enum TPlayerData
{
    
UserID,
    
Name[25],
    
Password[130],
    
IP[16],
    
GPCI[130],
    
PasswordAttempts,
    
bool:LoggedIn,
    
bool:InClassSelection,
    
// Player data
    
Money,
    
Score,
    
AdminLevel,
    
Speed
}
new 
APlayerData[MAX_PLAYERS][TPlayerData]; 
Consider this enum structure.

Most people do this when clearing all data in a player's account when a player disconnects or connects (to be sure the new player won't get data from the previous player):
PHP Code:
APlayerData[playerid][UserID] = 0;
APlayerData[playerid][Name][0] = 0;
APlayerData[playerid][Password][0] = 0;
APlayerData[playerid][IP][0] = 0;
APlayerData[playerid][GPCI][0] = 0;
APlayerData[playerid][PasswordAttempts] = 0;
APlayerData[playerid][LoggedIn] = false;
APlayerData[playerid][InClassSelection] = false;
APlayerData[playerid][Money] = 0;
APlayerData[playerid][Score] = 0;
APlayerData[playerid][AdminLevel] = 0;
APlayerData[playerid][Speed] = 0
While it's alot easier to do this:
PHP Code:
new temp[TPlayerData];
APlayerData[playerid] = temp
No need for hundreds of lines of code to reset your entire structure one variable at a time and no risk about forgetting to reset one of them.
Just reset them all at once.

I have no idea if it's faster and if it is, how much faster.
I never tested the speed of it, but it surely is less code and less risk to clear all your vars.
Reply


Messages In This Thread
Tiny But Super Optimizations - by Crayder - 28.04.2016, 18:13
Re: Tiny But Super Optimizations - by iGetty - 01.05.2016, 22:18
Re: Tiny But Super Optimizations - by lolumadd_ - 01.05.2016, 22:28
Re: Tiny But Super Optimizations - by Mauzen - 01.05.2016, 22:54
Re: Tiny But Super Optimizations - by AmigaBlizzard - 01.05.2016, 23:20
Re: Tiny But Super Optimizations - by Crayder - 02.05.2016, 02:44
Re: Tiny But Super Optimizations - by PrO.GameR - 02.05.2016, 11:54
Re: Tiny But Super Optimizations - by Vince - 02.05.2016, 12:39
Respuesta: Tiny But Super Optimizations - by aoEXE - 02.05.2016, 13:11
Re: Tiny But Super Optimizations - by Darkwood17 - 02.05.2016, 14:14
Re: Tiny But Super Optimizations - by Crayder - 02.05.2016, 14:26
Re: Tiny But Super Optimizations - by Konstantinos - 02.05.2016, 14:28
Re: Tiny But Super Optimizations - by Yashas - 02.05.2016, 15:27
Re: Tiny But Super Optimizations - by Mauzen - 02.05.2016, 17:52
Re: Tiny But Super Optimizations - by Slice - 02.05.2016, 22:51
Re: Tiny But Super Optimizations - by Macluawn - 03.05.2016, 21:54
Re: Tiny But Super Optimizations - by Crayder - 03.05.2016, 23:04
Re: Tiny But Super Optimizations - by SyS - 04.05.2016, 03:42
Re: Tiny But Super Optimizations - by Crayder - 04.05.2016, 04:24
Re: Tiny But Super Optimizations - by SyS - 04.05.2016, 08:14
Re: Tiny But Super Optimizations - by Marshall32 - 04.05.2016, 08:22
Re: Tiny But Super Optimizations - by Slice - 04.05.2016, 08:29
Re: Tiny But Super Optimizations - by GhostHacker - 04.05.2016, 08:33
Re: Tiny But Super Optimizations - by SyS - 04.05.2016, 08:34
Re: Tiny But Super Optimizations - by Ritzy2K - 04.05.2016, 09:10
Re: Tiny But Super Optimizations - by Wolfe - 04.05.2016, 09:22
Re: Tiny But Super Optimizations - by PrO.GameR - 04.05.2016, 10:23
Re: Tiny But Super Optimizations - by Donboo - 26.08.2016, 09:30
Re: Respuesta: Tiny But Super Optimizations - by PrO.GameR - 27.10.2016, 00:25
Respuesta: Re: Respuesta: Tiny But Super Optimizations - by Swedky - 29.10.2016, 06:05
Re: Respuesta: Re: Respuesta: Tiny But Super Optimizations - by Crayder - 29.10.2016, 17:57
Re: Tiny But Super Optimizations - by NeXoR - 31.10.2016, 03:02
Re: Tiny But Super Optimizations - by Freaksken - 15.11.2016, 13:04
Re: Tiny But Super Optimizations - by Awide - 24.11.2016, 20:16
Re: Tiny But Super Optimizations - by Crayder - 25.11.2016, 03:07
Re: Tiny But Super Optimizations - by Yashas - 25.11.2016, 04:24

Forum Jump:


Users browsing this thread: 1 Guest(s)