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
endwhich seems worth it for another 20 lines of code for |
Closes #57 by implementing
skipcharsandpeek(io, Char), and also optimizingread(io, Char), forBufferedInputStream.