REFACTORING: supporting a list of bytes #685

Merged
merged 1 commit into from May 1, 2013

Projects

None yet

2 participants

@josedonizetti
Member

This will help fix the issues with IO.ungetc

@headius
Member
headius commented May 1, 2013

Nice... ungetc has been dragging on for too long. Will review and merge.

@headius
Member
headius commented May 1, 2013

Changes look good, and I'll merge them in. We may want to do our own lighter-weight implementation of the ungot characters buffer, so ungetting a byte doesn't end up creating both a Byte and a LinkedList node.

@headius headius merged commit e8ede87 into jruby:master May 1, 2013

1 check failed

Details default The Travis build failed
@josedonizetti
Member

@headius What I could do is change the code to be lazy, and only creating the linked list when trying to ungetc more than one byte. How that sounds?

@headius
Member
headius commented May 1, 2013

@josedonizetti That's a good start, since most IO users won't ever ungetc. However I was thinking of something more like a byte-based ArrayList where we could simply unget an additional byte by setting a byte[] element and moving an offset.

Heh, as I wrote this it suddenly occurred to me: we have ByteList. So what if we just use a ByteList and ungetc appends a byte into it and removes bytes from it, rather than using LinkedList? I don't think the code would change much.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment