Compiling with "case"
#1

Example :

Код HTML:
case 1..5:{
// Some stuff
}

case 6..10:{
// Some stuff
}

case 50..52:{
// Some stuff
}

case 600..769:{
// Some stuff
}
And when I compile, it compiles me very, very slowly... It took ~2 minutes to compile, when my code is only 300 lines length... Is it has to be like that when I use case or I do something wrong?

It only happens when I use many "case".
Reply
#2

case won't cause lag. Did you include y_ini?
Because y_ini causes lag.
Reply
#3

I can also approve what ATGOggy said, I had many snippets of code in my script with cases similar to yours and it didn't cause lag.
After including y_ini in my code, it took more time to compile the script but it's never been compiling for over ~15 seconds or so.
Reply
#4

I said at the top...

Quote:
Originally Posted by Supermaxultraswag
Посмотреть сообщение
It only happens when I use many "case".
And no, Im not using Y_ini, I only use a_samp and foreach
Reply
#5

How many cases do you actually have and what exactly are you switching through? If you need this many cases then there's usually a better way to reach your goal.
Reply
#6

Quote:
Originally Posted by ******
Посмотреть сообщение
1) I don't see what y_ini has to do with this.

2) The rest of your post is also wrong! "switch" expands case ranges, so:

pawn Код:
case 5 .. 7:
{
}
Becomes:

pawn Код:
case 5, 6, 7:
{
}
The larger the range, the more numbers is expands to, every one of which is then included. I've seen scripts bloat and fail to compile just because of a vast range in "switch". As Vince said, this is probably not the best thing to use - consider "if" instead:

pawn Код:
if (5 <= n <= 7)
{
}
Though "5 .. 7" is fine for switch, "100 .. 999" would kill it.
Lol, I was using "case 6000..90000:", so... Thanks for the answers, I change case into if
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)