private static int nthNonAsciiCompatible(Encoding enc, byte[]bytes, int p, int end, int n) { while (p < end && n-- != 0) { p += length(enc, bytes, p, end); } return p; }
private static int nthNonAsciiCompatible(Encoding enc, byte[]bytes, int p, int end, int n) { while (p < end && n-- != 0) { p += length(enc, bytes, p, end); } return p; }
private static int nthNonAsciiCompatible(Encoding enc, byte[]bytes, int p, int end, int n) { while (p < end && n-- != 0) { p += length(enc, bytes, p, end); } return p; }
private static int nthNonAsciiCompatible(Encoding enc, byte[]bytes, int p, int end, int n) { while (p < end && n-- != 0) { p += length(enc, bytes, p, end); } return p; }
private static int nthAsciiCompatible(Encoding enc, byte[]bytes, int p, int end, int n) { while (p < end && n > 0) { int end2 = p + n; if (end < end2) return end; if (Encoding.isAscii(bytes[p])) { int p2 = searchNonAscii(bytes, p, end2); if (p2 == -1) return end2; n -= p2 - p; p = p2; } int cl = length(enc, bytes, p, end); p += cl; n--; } return n != 0 ? end : p; }
private static int nthAsciiCompatible(Encoding enc, byte[]bytes, int p, int end, int n) { while (p < end && n > 0) { int end2 = p + n; if (end < end2) return end; if (Encoding.isAscii(bytes[p])) { int p2 = searchNonAscii(bytes, p, end2); if (p2 == -1) return end2; n -= p2 - p; p = p2; } int cl = length(enc, bytes, p, end); p += cl; n--; } return n != 0 ? end : p; }
private static int nthAsciiCompatible(Encoding enc, byte[]bytes, int p, int end, int n) { while (p < end && n > 0) { int end2 = p + n; if (end < end2) return end; if (Encoding.isAscii(bytes[p])) { int p2 = searchNonAscii(bytes, p, end2); if (p2 == -1) return end2; n -= p2 - p; p = p2; } int cl = length(enc, bytes, p, end); p += cl; n--; } return n != 0 ? end : p; }
private static int nthAsciiCompatible(Encoding enc, byte[]bytes, int p, int end, int n) { while (p < end && n > 0) { int end2 = p + n; if (end < end2) return end; if (Encoding.isAscii(bytes[p])) { int p2 = searchNonAscii(bytes, p, end2); if (p2 == -1) return end2; n -= p2 - p; p = p2; } int cl = length(enc, bytes, p, end); p += cl; n--; } return n != 0 ? end : p; }
public static int strLength(Encoding enc, byte[]bytes, int p, int end) { if (enc.isFixedWidth()) { return (end - p + enc.minLength() - 1) / enc.minLength(); } else if (enc.isAsciiCompatible()) { int c = 0; while (p < end) { if (Encoding.isAscii(bytes[p])) { int q = searchNonAscii(bytes, p, end); if (q == -1) return c + (end - p); c += q - p; p = q; } p += length(enc, bytes, p, end); c++; } return c; } int c; for (c = 0; end > p; c++) p += length(enc, bytes, p, end); return c; }
public static int strLength(Encoding enc, byte[]bytes, int p, int end) { if (enc.isFixedWidth()) { return (end - p + enc.minLength() - 1) / enc.minLength(); } else if (enc.isAsciiCompatible()) { int c = 0; while (p < end) { if (Encoding.isAscii(bytes[p])) { int q = searchNonAscii(bytes, p, end); if (q == -1) return c + (end - p); c += q - p; p = q; } p += length(enc, bytes, p, end); c++; } return c; } int c; for (c = 0; end > p; c++) p += length(enc, bytes, p, end); return c; }
private IRubyObject each_charCommon18(ThreadContext context, Block block) { byte bytes[] = value.getUnsafeBytes(); int p = value.getBegin(); int end = p + value.getRealSize(); Ruby runtime = context.runtime; Encoding enc = runtime.getKCode().getEncoding(); ByteList val = value.shallowDup(); while (p < end) { int n = StringSupport.length(enc, bytes, p, end); block.yield(context, makeShared19(runtime, val, p-val.getBegin(), n)); p += n; } return this; }
private IRubyObject each_charCommon18(ThreadContext context, Block block) { byte bytes[] = value.getUnsafeBytes(); int p = value.getBegin(); int end = p + value.getRealSize(); Ruby runtime = context.runtime; Encoding enc = runtime.getKCode().getEncoding(); ByteList val = value.shallowDup(); while (p < end) { int n = StringSupport.length(enc, bytes, p, end); block.yield(context, makeShared19(runtime, val, p-val.getBegin(), n)); p += n; } return this; }
public IRubyObject each_charInternal(final ThreadContext context, final Block block) { checkReadable(); Ruby runtime = context.runtime; ByteList bytes = ptr.string.getByteList(); int len = bytes.getRealSize(); int end = bytes.getBegin() + len; Encoding enc = runtime.is1_9() ? bytes.getEncoding() : runtime.getKCode().getEncoding(); while (ptr.pos < len) { int pos = (int) ptr.pos; int n = StringSupport.length(enc, bytes.getUnsafeBytes(), pos, end); if (len < pos + n) n = len - pos; ptr.pos += n; block.yield(context, ptr.string.makeShared19(runtime, pos, n)); } return this; }
public IRubyObject each_charInternal(final ThreadContext context, final Block block) { checkReadable(); Ruby runtime = context.runtime; ByteList bytes = ptr.string.getByteList(); int len = bytes.getRealSize(); int end = bytes.getBegin() + len; Encoding enc = runtime.is1_9() ? bytes.getEncoding() : runtime.getKCode().getEncoding(); while (ptr.pos < len) { int pos = (int) ptr.pos; int n = StringSupport.length(enc, bytes.getUnsafeBytes(), pos, end); if (len < pos + n) n = len - pos; ptr.pos += n; block.yield(context, ptr.string.makeShared19(runtime, pos, n)); } return this; }
private IRubyObject each_charCommon19(ThreadContext context, Block block) { byte bytes[] = value.getUnsafeBytes(); int p = value.getBegin(); int end = p + value.getRealSize(); Encoding enc = value.getEncoding(); Ruby runtime = context.runtime; ByteList val = value.shallowDup(); boolean isUSASCII = val.getEncoding() == USASCIIEncoding.INSTANCE; boolean is7bit = getCodeRange() == StringSupport.CR_7BIT; // if 7bit, don't use more expensive length logic // if USASCII, use preallocated single-byte ByteLists while (p < end) { int n = is7bit ? 1 : StringSupport.length(enc, bytes, p, end); RubyString str; if (n == 1 && isUSASCII) { str = newStringShared(runtime, RubyFixnum.SINGLE_CHAR_BYTELISTS19[bytes[p] & 0xFF], StringSupport.CR_7BIT); } else { str = makeShared19(runtime, val, p-value.getBegin(), n); } block.yield(context, str); p += n; } return this; }
private IRubyObject each_charCommon19(ThreadContext context, Block block) { byte bytes[] = value.getUnsafeBytes(); int p = value.getBegin(); int end = p + value.getRealSize(); Encoding enc = value.getEncoding(); Ruby runtime = context.runtime; ByteList val = value.shallowDup(); boolean isUSASCII = val.getEncoding() == USASCIIEncoding.INSTANCE; boolean is7bit = getCodeRange() == StringSupport.CR_7BIT; // if 7bit, don't use more expensive length logic // if USASCII, use preallocated single-byte ByteLists while (p < end) { int n = is7bit ? 1 : StringSupport.length(enc, bytes, p, end); RubyString str; if (n == 1 && isUSASCII) { str = newStringShared(runtime, RubyFixnum.SINGLE_CHAR_BYTELISTS19[bytes[p]], StringSupport.CR_7BIT); } else { str = makeShared19(runtime, val, p-value.getBegin(), n); } block.yield(context, str); p += n; } return this; }
public IRubyObject getchCommon(ThreadContext context, boolean is1_9) { check(); clearMatched(); Ruby runtime = context.runtime; ByteList value = str.getByteList(); if (pos >= value.getRealSize()) return context.nil; int len; if (is1_9) { Encoding enc = str.getEncoding(); len = enc.isSingleByte() ? 1 : StringSupport.length(enc, value.getUnsafeBytes(), value.getBegin() + pos, value.getBegin() + value.getRealSize()); } else { Encoding enc = runtime.getKCode().getEncoding(); len = enc.isSingleByte() ? 1 : enc.length(value.getUnsafeBytes(), value.getBegin() + pos, value.getBegin() + value.getRealSize()); } if (pos + len > value.getRealSize()) len = value.getRealSize() - pos; lastPos = pos; pos += len; setMatched(); adjustRegisters(); return extractRange(runtime, lastPos + beg, lastPos + end); }
public IRubyObject getchCommon(ThreadContext context, boolean is1_9) { check(); clearMatched(); Ruby runtime = context.runtime; ByteList value = str.getByteList(); if (pos >= value.getRealSize()) return context.nil; int len; if (is1_9) { Encoding enc = str.getEncoding(); len = enc.isSingleByte() ? 1 : StringSupport.length(enc, value.getUnsafeBytes(), value.getBegin() + pos, value.getBegin() + value.getRealSize()); } else { Encoding enc = runtime.getKCode().getEncoding(); len = enc.isSingleByte() ? 1 : enc.length(value.getUnsafeBytes(), value.getBegin() + pos, value.getBegin() + value.getRealSize()); } if (pos + len > value.getRealSize()) len = value.getRealSize() - pos; lastPos = pos; pos += len; setMatched(); adjustRegisters(); return extractRange(runtime, lastPos + beg, lastPos + end); }
public IRubyObject getchCommon(ThreadContext context, boolean is1_9) { check(); clearMatched(); Ruby runtime = context.runtime; ByteList value = str.getByteList(); if (pos >= value.getRealSize()) return runtime.getNil(); int len; if (is1_9) { Encoding enc = str.getEncoding(); len = enc.isSingleByte() ? 1 : StringSupport.length(enc, value.getUnsafeBytes(), value.getBegin() + pos, value.getBegin() + value.getRealSize()); } else { Encoding enc = runtime.getKCode().getEncoding(); len = enc.isSingleByte() ? 1 : enc.length(value.getUnsafeBytes(), value.getBegin() + pos, value.getBegin() + value.getRealSize()); } if (pos + len > value.getRealSize()) len = value.getRealSize() - pos; lastPos = pos; pos += len; setMatched(); adjustRegisters(); return extractRange(runtime, lastPos + beg, lastPos + end); }
public IRubyObject getchCommon(ThreadContext context, boolean is1_9) { check(); clearMatched(); Ruby runtime = context.runtime; ByteList value = str.getByteList(); if (pos >= value.getRealSize()) return runtime.getNil(); int len; if (is1_9) { Encoding enc = str.getEncoding(); len = enc.isSingleByte() ? 1 : StringSupport.length(enc, value.getUnsafeBytes(), value.getBegin() + pos, value.getBegin() + value.getRealSize()); } else { Encoding enc = runtime.getKCode().getEncoding(); len = enc.isSingleByte() ? 1 : enc.length(value.getUnsafeBytes(), value.getBegin() + pos, value.getBegin() + value.getRealSize()); } if (pos + len > value.getRealSize()) len = value.getRealSize() - pos; lastPos = pos; pos += len; setMatched(); adjustRegisters(); return extractRange(runtime, lastPos + beg, lastPos + end); }