Advertisement
Guest User

Untitled

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