@SuppressWarnings("deprecation") public static int utf8Length(byte[] bytes, int p, int end) { int len = 0; if (ARRAY_BYTE_BASE_OFFSET > 0) { // Unsafe if (end - p > LONG_SIZE * 2) { int ep = ~LOWBITS & (p + LOWBITS); while (p < ep) { if ((bytes[p++] & 0xc0 /*utf8 lead byte*/) != 0x80) len++; } final Unsafe unsafe = org.jruby.util.unsafe.UnsafeHolder.U; int eend = ~LOWBITS & end; while (p < eend) { len += countUtf8LeadBytes(unsafe.getLong(bytes, (long) (ARRAY_BYTE_BASE_OFFSET + p))); p += LONG_SIZE; } } } while (p < end) { if ((bytes[p++] & 0xc0 /*utf8 lead byte*/) != 0x80) len++; } return len; }
@SuppressWarnings("deprecation") public static int utf8Length(byte[]bytes, int p, int end) { int len = 0; if (UNSAFE != null) { if (end - p > LONG_SIZE * 2) { int ep = ~LOWBITS & (p + LOWBITS); while (p < ep) { if ((bytes[p++] & 0xc0 /*utf8 lead byte*/) != 0x80) len++; } Unsafe us = (Unsafe)UNSAFE; int eend = ~LOWBITS & end; while (p < eend) { len += countUtf8LeadBytes(us.getLong(bytes, OFFSET + p)); p += LONG_SIZE; } } } while (p < end) { if ((bytes[p++] & 0xc0 /*utf8 lead byte*/) != 0x80) len++; } return len; }
@SuppressWarnings("deprecation") public static int utf8Length(byte[] bytes, int p, int end) { int len = 0; if (ARRAY_BYTE_BASE_OFFSET > 0) { // Unsafe if (end - p > LONG_SIZE * 2) { int ep = ~LOWBITS & (p + LOWBITS); while (p < ep) { if ((bytes[p++] & 0xc0 /*utf8 lead byte*/) != 0x80) len++; } final Unsafe unsafe = org.jruby.util.unsafe.UnsafeHolder.U; int eend = ~LOWBITS & end; while (p < eend) { len += countUtf8LeadBytes(unsafe.getLong(bytes, (long) (ARRAY_BYTE_BASE_OFFSET + p))); p += LONG_SIZE; } } } while (p < end) { if ((bytes[p++] & 0xc0 /*utf8 lead byte*/) != 0x80) len++; } return len; }
@SuppressWarnings("deprecation") public static int utf8Length(byte[]bytes, int p, int end) { int len = 0; if (UNSAFE != null) { if (end - p > LONG_SIZE * 2) { int ep = ~LOWBITS & (p + LOWBITS); while (p < ep) { if ((bytes[p++] & 0xc0 /*utf8 lead byte*/) != 0x80) len++; } Unsafe us = (Unsafe)UNSAFE; int eend = ~LOWBITS & end; while (p < eend) { len += countUtf8LeadBytes(us.getLong(bytes, OFFSET + p)); p += LONG_SIZE; } } } while (p < end) { if ((bytes[p++] & 0xc0 /*utf8 lead byte*/) != 0x80) len++; } return len; }
@SuppressWarnings("deprecation") public static int utf8Nth(byte[]bytes, int p, int end, int n) { if (UNSAFE != null) { if (n > LONG_SIZE * 2) { int ep = ~LOWBITS & (p + LOWBITS); while (p < ep) { if ((bytes[p++] & 0xc0 /*utf8 lead byte*/) != 0x80) n--; } Unsafe us = (Unsafe)UNSAFE; int eend = ~LOWBITS & end; do { n -= countUtf8LeadBytes(us.getLong(bytes, OFFSET + p)); p += LONG_SIZE; } while (p < eend && n >= LONG_SIZE); } } while (p < end) { if ((bytes[p] & 0xc0 /*utf8 lead byte*/) != 0x80) { if (n-- == 0) break; } p++; } return p; }
@SuppressWarnings("deprecation") public static int utf8Nth(byte[]bytes, int p, int end, int n) { if (UNSAFE != null) { if (n > LONG_SIZE * 2) { int ep = ~LOWBITS & (p + LOWBITS); while (p < ep) { if ((bytes[p++] & 0xc0 /*utf8 lead byte*/) != 0x80) n--; } Unsafe us = (Unsafe)UNSAFE; int eend = ~LOWBITS & end; do { n -= countUtf8LeadBytes(us.getLong(bytes, OFFSET + p)); p += LONG_SIZE; } while (p < eend && n >= LONG_SIZE); } } while (p < end) { if ((bytes[p] & 0xc0 /*utf8 lead byte*/) != 0x80) { if (n-- == 0) break; } p++; } return p; }