I'm sure someone out there knows how to get the address of an array using the Unsafe class. I've looked at related posts and there wasn't actually an answer.
static Unsafe _u;
static int Atoi8(char[] s, int i0, int cb) {
int n = 0;
// loop to process the valid number chars.
int baseOffset = _u.arrayBaseOffset(s.getClass()); <-- returns 16 oops!
for (int i=i0 ; i<i0+cb ; ++i) {
char ch = _u.getChar(baseOffset + i);
n = n*10 + ((ch <= '0') ? 0 : ch - '0');
}
return n;
}
PLEASE Lets not make this a discussion about the perils of unsafe code, pre-optimzation, using a different language, or performance vs maintainability!