Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 10 additions & 9 deletions ext/jruby/org/jruby/ext/strscan/RubyStringScanner.java
Original file line number Diff line number Diff line change
Expand Up @@ -513,26 +513,27 @@ public IRubyObject scan_byte(ThreadContext context) {
Ruby runtime = context.runtime;
check(context);
clearMatched();
if (curr >= str.getByteList().getRealSize()) return context.nil;

byte[] bytes = str.getBytes();
ByteList byteList = str.getByteList();
int curr = this.curr;
if (curr >= byteList.getRealSize()) return context.nil;

byte bite = bytes[curr];
int bite = byteList.get(curr);
prev = curr;
curr++;
this.curr++;

setMatched();
adjustRegisters();
return RubyFixnum.newFixnum(context.runtime, bite & 0xff);
return RubyFixnum.newFixnum(runtime, bite);
}

@JRubyMethod(name = "peek_byte")
public IRubyObject peek_byte(ThreadContext context) {
Ruby runtime = context.runtime;
check(context);
if (curr >= str.getByteList().getRealSize()) return context.nil;
ByteList byteList = str.getByteList();
int curr = this.curr;
if (curr >= byteList.getRealSize()) return context.nil;

return RubyFixnum.newFixnum(context.runtime, (str.getBytes()[curr]) & 0xff);
return RubyFixnum.newFixnum(context.runtime, byteList.get(curr));
}

@JRubyMethod(name = "peek")
Expand Down