]> git.ipfire.org Git - thirdparty/systemd.git/commit
basic/fileio: optimize buffer sizes in read_full_virtual_file()
authorZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>
Thu, 25 Mar 2021 11:10:32 +0000 (12:10 +0100)
committerZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>
Fri, 26 Mar 2021 14:53:50 +0000 (15:53 +0100)
commita9899ff3588801b825322d40564b271c7216fe46
tree59f03b231fe7b7b6ae871b00f25a7b085ae846a3
parentca79564309e87f1cd92f7c79a03fccb792cca274
basic/fileio: optimize buffer sizes in read_full_virtual_file()

We'd proceed rather inefficiently: the initial buffer size was LINE_MAX/2,
i.e. only 1k. We can read 4k at the same cost.

Also, we'd try to allocate 1025, 2049, 4097 bytes, i.e. always one higher than
the power-of-two size. Effectively the allocation would be bigger, and we'd
waste the additional space. So let's allocate aligned to the power-of-two size.
size=4095, 8191, 16383, so we allocate 4k, 8k, 16k.
src/basic/fileio.c