]> git.ipfire.org Git - thirdparty/rrdtool-1.x.git/commit
Improved buffering (#792)
authorSven Panne <svenpanne@gmail.com>
Wed, 31 May 2017 12:14:42 +0000 (14:14 +0200)
committerTobias Oetiker <tobi@oetiker.ch>
Wed, 31 May 2017 12:14:42 +0000 (14:14 +0200)
commit698db1350e7c15eccc9723f3fdd3a8240897d5eb
treea46ed9c38dddc33872dec3226fb1ca8a446b6692
parent86535fdf012e73cd861e6b10678e695c91b38512
Improved buffering (#792)

* Encapsulate access to write buffer.

Fixed ssize_t vs. size_t confusion on the way.

* Improve wbuf_append's time complexity from linear to amortized constant.

This is done by the usual technique employed in many, may libraries out
there (C++'s vector, Java's ArrayList, Python's list, ...): Distinguish
between the size and the capacity of the underlying container.  The capacity
grows by some *factor* (2 in our case) if it is too small, amortizing the
needed allocations/copies over time.

In a nutshell: Adding a single character to the buffer can now be done in
constant amortized time.

* Simplify and improve handle_request_fetch.

Now that add_response_info is efficient (thanks to the improved
wbuf_append), we can vastly simplify handle_request_fetch and even remove
some arbitrary length restrictions on the way.
src/rrd_daemon.c