Created
March 20, 2014 21:46
-
-
Save chuckremes/9674596 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# before | |
def reset! | |
@start = @used = 0 | |
@eof = false | |
@write_synced = true | |
end | |
def discard(skip) | |
while @start < @used | |
break unless @storage[@start] == skip | |
@start += 1 | |
end | |
end | |
# after some "fp" is added | |
class IOVars | |
def initialize(start = 0, used = 0, eof = false, write_synced = true, *args) | |
@start = start | |
@used = used | |
@eof = eof | |
@write_synced = write_synced | |
# other ivars initialized here... | |
end | |
def reset! | |
new | |
end | |
def advance_start(count) | |
new(@start + count, @used, @write_synced) | |
end | |
end | |
def discard(skip) | |
while @ivars.remaining_bytes? | |
break unless @storage[@ivars.start] == skip | |
@ivars = @iovars.advance_start(1) | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment