whats better - 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)
+---- Forum: Help Archive (
https://sampforum.blast.hk/forumdisplay.php?fid=89)
+---- Thread: whats better (
/showthread.php?tid=177985)
whats better -
GaGlets(R) - 20.09.2010
What would be better?:
To create many "new" or f*ck it all under enums ?
pawn Код:
new bla;
new bla2;
new bla3;
etc with new
or this would be faster, more compact
pawn Код:
enum
{
bla,
bla2,
bla3,
bla4,
etttccc
}
Re: whats better -
Toni - 20.09.2010
Declarations aren't the same things as enum's.
You would need a double array for a enum, and yet what would you fill out for the first array i.e playerid.
Just use 1 declaration, but with many commas separating them.
I.e. new i, e, f, u, j, k;
Re: whats better -
Kyosaur - 20.09.2010
Well, if you are using an enum just like that (for constants) than that is undoubtedly the best route to take.
If your planing on shoving it in an array and simply made a small snytax error, then the answer changes. Variables are faster to access than arrays are, but the answer to "which is better" really depends on much work you are willing to put in for this small speed difference, and really what your variables are used for.
Here's the speed order from fastest to slowest
Quote:
Originally posted by: ******
* Nothing
* Constants
* Variables
* Arrays
* Native functions
* Custom functions
* Remote functions
|
Quote:
Originally Posted by The Toni
Declarations aren't the same things as enum's.
You would need a double array for a enum, and yet what would you fill out for the first array i.e playerid.
Just use 1 declaration, but with many commas separating them.
I.e. new i, e, f, u, j, k;
|
That is simply not true at all, you can shove an enum into an array with a single dimension.
Re: whats better -
Toni - 20.09.2010
Quote:
Originally Posted by Kyosaur
Well, if you are using an enum just like that (for constants) than that is undoubtedly the best route to take.
If your planing on shoving it in an array and simply made a small snytax error, then the answer changes. Variables are faster to access than arrays are, but the answer to "which is better" really depends on much work you are willing to put in for this small speed difference, and really what your variables are used for.
Here's the speed order from fastest to slowest
That is simply not true at all, you can shove an enum into an array with a single dimension.
|
Ah, looks like I learned something today. Wouldn't it be a little weird to use single arrays with enum's?
Re: whats better -
Kyosaur - 20.09.2010
Quote:
Originally Posted by The Toni
Ah, looks like I learned something today. Wouldn't it be a little weird to use single arrays with enum's?
|
I dont see how. It would be exactly the same as using it in a multidimensional array. Lets say you have an array filled with all your server information (Players,objects,vehicles, etc) is it not easier to use the names than to remember an array index?