Indexing constant arrays
#1

I just had an idea regarding optimizing. Constant arrays could easily be replaced with defines using {...}
However I couldnt figure out a way to index these defined arrays.

pawn Код:
({1,2,3})+1;
//error 033: array must be indexed (variable "-unknown-")
({1,2,3})[0]+1;
//error 029: invalid expression, assumed zero
{1,2,3}+1; {1,2,3}[0]+1;
//error 001: expected token: ";", but found "}"
Reply
#2

You shouldn't replace constant arrays with definitions simply for optimization. There are many reasons global constants are preferred and used more widely (just not in SA:MP, due to people simply copying code or learning off other code). Only time I'd really suggesting doing so is to take advantage of the compilers concatenation.
Reply
#3

True, it will just move the memory to another section.
However, would still be interesting to know if it is possible at all.
Reply
#4

Thanks for the answer.
Im currently experimenting a bit with the const tag, but my observation so far is that it increases the used memory, instead of reducing or just moving it. But that shouldnt be topic of this thread.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)