SA-MP Forums

Go Back   SA-MP Forums > SA-MP Scripting and Plugins > Scripting Help

Reply
 
Thread Tools Display Modes
Old 29/03/2020, 11:25 AM   #1
Adamoneoone
Huge Clucker
 
Join Date: Sep 2014
Posts: 495
Reputation: 37
Default Max enum size / big enums drawbacks?

Hello everyone, i'm using an enum which stores a lot of player data, and It's slowly beginning to go above the 50 elements mark, and this number will be steadily raising towards 100 (certainly more later on) and I'm wondering whether this will have some performance issues, as I don't really want to make several enums with different player info variables, I think it'll get really messy in a short amount of time with having such a structure for instance
pawn Code:
enum_1:
{
     bla...
};

enum_2:
{
     bla...
};

enum_3:
{
     bla...
};

new pInfo1[MAX_PLAYERS][enum_1];
new pInfo2[MAX_PLAYERS][enum_2];
...
.

Any input is appreciated, thanks!
Adamoneoone is offline   Reply With Quote
Old 29/03/2020, 11:35 AM   #2
YouShootIDodge
Big Clucker
 
Join Date: May 2019
Posts: 64
Reputation: 14
Default Re: Max enum size / big enums drawbacks?

The more enums you create, the more arrays you will use which ofc uses alot of data, even the empty array having the size of MAX_PLAYERS is memory consuming, so it's better if you use a single enum in this case.

EDIT: I'm not sure but as far as i know, an array with a size of MAX_PLAYERS, let's say 1000 and a 2nd dimension with a size of 100 (number of elements in enum) will have the same effect as 1000x100 variables.
YouShootIDodge is online now   Reply With Quote
Old 29/03/2020, 12:00 PM   #3
Calisthenics
High-roller
 
Join Date: May 2018
Posts: 1,229
Reputation: 205
Default Re: Max enum size / big enums drawbacks?

Quote:
Originally Posted by YouShootIDodge View Post
The more enums you create, the more arrays you will use which ofc uses alot of data, even the empty array having the size of MAX_PLAYERS is memory consuming, so it's better if you use a single enum in this case.
No.

Many items in enumerators, huge scripts, timers with a lot of code unrelated to each other, huge queries that update EVERYTHING even when they never changed. They are not better, they are worse. Split them when you can.

Quote:
Originally Posted by Adamoneoone View Post
as I don't really want to make several enums with different player info variables, I think it'll get really messy in a short amount of time with having such a structure for instance
Create helper functions to set/get values.
__________________

Last edited by Calisthenics; 29/03/2020 at 12:51 PM.
Calisthenics is offline   Reply With Quote
Old 29/03/2020, 12:57 PM   #4
DRIFT_HUNTER
High-roller
 
Join Date: Oct 2009
Posts: 2,135
Reputation: 215
Default Re: Max enum size / big enums drawbacks?

Well big enums should not have impact on performance. It doesnt matter if you add some variable in array or as single variable (not for performance).

The only potential drawback could be memory allocation since enums are used in arrays, but if you hit that problem then it means you have run out of RAM.
DRIFT_HUNTER is offline   Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
No specific size in enum JaydenJason Scripting Help 5 27/08/2016 01:06 PM
enum size +rep iBots Scripting Help 13 22/04/2015 08:11 PM
Enum of enums Misiur Scripting Help 0 05/08/2012 10:05 AM
Why do enums with a certain value give a huge AMX size? Lorenc_ Scripting Help 2 23/11/2011 07:59 PM
Array size of 1 doesn't work within enums PowerPC603 Bug Reports 7 01/09/2011 02:10 PM


All times are GMT. The time now is 02:47 PM.


Powered by vBulletin® Version 3.8.6
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.