buffer: improve read/write speed with assert

Improved assert checks so additional parameters are correctly checked
(e.g. that offset isn't negative). Which has improved overall execution
time.