Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // invariant: next LOOKAHEAD characters of bufc are available for direct indexing.
- // note that bufc_refill isn't the end of the indexable range but LOOKAHEAD before that.
- // when we refill the buffer, we have to carry forward the last LOOKAHEAD-1 characters to the
- // beginning of the new buffer.
- // if you're chaining mmapped file segments, that means you need an interstitial non-mmap buffer
- // to join the beginning and end of the two segments.
- // if we reach the true end of the buffer, pad with 0s so lookahead doesn't index out of bounds.
- #define nextc() (bufc != bufc_refill ? c = *bufc++ : nextc_slow())
- // can also advance by larger number of characters in one step by an inequality check.
- // note this avoids the refill-sentinel of the previous solution. once you're doing lookahead,
- // there's not much point (my thinking with the refill sentinel is that you're reading *bufc to set
- // c, so you might as well use it rather than doing a pointer compare vs something else you'd have
- // to load first, but that's no longer possible once the sentinel value is at a different point from
- // the read value).
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement