buffer: Refacor the basic buffer.
buffer: Refacor the basic buffer.

This change improves the read/write perfomance of Buffer
by at least 100x and eliminates a nasty performance hit when
large ringbuffers are used.

This often caused unnecessary cache drops in players since
the reads could become very slow if the buffer had grown a bit.

okaywit/livestreamer,bastimeyer/streamlink,Saturn/livestreamer,jtsymon/livestreamer,ethanhlc/streamlink,javiercantero/streamlink,chhe/livestreamer,hmit/livestreamer,sbstp/streamlink,fishscene/streamlink,wlerin/streamlink,ethanhlc/streamlink,fishscene/streamlink,wolftankk/livestreamer,gtmanfred/livestreamer,back-to/streamlink,Feverqwe/livestreamer,sbstp/streamlink,gtmanfred/livestreamer,chhe/streamlink,charmander/livestreamer,chrippa/livestreamer,derrod/livestreamer,wlerin/streamlink,wolftankk/livestreamer,streamlink/streamlink,chhe/livestreamer,Feverqwe/livestreamer,caorong/livestreamer,flijloku/livestreamer,Saturn/livestreamer,beardypig/streamlink,blxd/livestreamer,beardypig/streamlink,Klaudit/livestreamer,chhe/streamlink,mmetak/streamlink,javiercantero/streamlink,programming086/livestreamer,Masaz-/livestreamer,melmorabity/streamlink,Dobatymo/livestreamer,chrippa/livestreamer,back-to/streamlink,bastimeyer/streamlink,caorong/livestreamer,flijloku/livestreamer,streamlink/streamlink,melmorabity/streamlink,breunigs/livestreamer,mmetak/streamlink,programming086/livestreamer,blxd/livestreamer,gravyboat/streamlink,charmander/livestreamer,gravyboat/streamlink,breunigs/livestreamer,okaywit/livestreamer,intact/livestreamer,Dobatymo/livestreamer,lyhiving/livestreamer,Masaz-/livestreamer,derrod/livestreamer,hmit/livestreamer,Klaudit/livestreamer,jtsymon/livestreamer,intact/livestreamer,lyhiving/livestreamer