14.06.2011, 13:08
Very nice!
//Edit: To the speed comparator above:
This is no WTF. 8-bit and 32-bit is already built in in PAWN, 16-bit not. So 16-bit needs some calculations and this takes time.
//Edit 2: Why is there a DBIT_VAR?
You could just do this:
//Edit 3:
I'm not sure, but maybe you should round the real array size up:
Assume you want 31 16-bit cells, now you divide 31 by 2 and recieve 15. So there would be no 31st cell...
If you round up, there's a 32nd 16-bit cells, which you don't need, but it's still better.
Too much is better than not enough.
//Edit: To the speed comparator above:
This is no WTF. 8-bit and 32-bit is already built in in PAWN, 16-bit not. So 16-bit needs some calculations and this takes time.
//Edit 2: Why is there a DBIT_VAR?
pawn Код:
#define Bit16_Get(%0,%1) \
(((DBITS_VAR=(%1)),DBITS_VAR&1)?(%0[(%1)/2]&0x0000FFFF):((%0[(%1)/2]>>>16)&0x0000FFFF))
pawn Код:
#define Bit16_Get(%0,%1) \
((((%1)&1)?(%0[(%1)/2]&0x0000FFFF):((%0[(%1)/2]>>>16)&0x0000FFFF))
pawn Код:
#define Bit16:%0<%1> \
%0[(%1)/2]
pawn Код:
#define Bit16:%0<%1> \
%0[((%1)+2)/2] // Round up here
If you round up, there's a 32nd 16-bit cells, which you don't need, but it's still better.
Too much is better than not enough.