-
Notifications
You must be signed in to change notification settings - Fork 20
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
support skipchars and peek(io, Char) #77
Conversation
Note that the Update: see #78 |
Codecov ReportPatch coverage:
Additional details and impacted files@@ Coverage Diff @@
## master #77 +/- ##
==========================================
+ Coverage 85.82% 87.29% +1.46%
==========================================
Files 5 5
Lines 381 425 +44
==========================================
+ Hits 327 371 +44
Misses 54 54
☔ View full report in Codecov by Sentry. |
CI failure is due to JuliaLang/julia#50532 — need to decide what we want the behavior to be. Update:: fixed following JuliaLang/julia#50552 |
For the record, on a simple benchmark s = randstring("xα∆🐨", 100) * ' '
io = BufferedInputStream(IOBuffer(s));
@btime skipchars(!=(' '), seekstart($io)); this is about 20% faster than the much simpler implementation: function skipchars(predicate, stream::BufferedInputStream; linecomment=nothing)
BufferedStreams.checkopen(stream)
while !eof(stream)
mark(stream)
c = read(stream, Char)
if c === linecomment
error("unimplemented") # not benchmarking line comments
elseif predicate(c)
unmark(stream)
else
reset(stream)
break
end
end
return stream
end which seems worth it for another 20 lines of code for |
Closes #57 by implementing
skipchars
andpeek(io, Char)
, and also optimizingread(io, Char)
, forBufferedInputStream
.