]> git.ipfire.org Git - thirdparty/ccache.git/commit
Read/write optimizations (#551)
authorErik Johansson <erik@ejohansson.se>
Sun, 1 Mar 2020 20:30:06 +0000 (21:30 +0100)
committerGitHub <noreply@github.com>
Sun, 1 Mar 2020 20:30:06 +0000 (21:30 +0100)
commited45b522a79e383a257eb7759414ed2943a97fc5
tree16fdafc3bae3a029297110c70c032066b10b6167
parentdf961358240487afdc4a92eb4bc7db25e6f931de
Read/write optimizations (#551)

* Avoid one extra read call after the final bytes are read

If read returns less then the requested number of bytes, the file is at
EOF. This can be used in all places where a read is done, but it makes extra
impact in read_file where if the buffer is made one byte bigger than needed,
EOF can be detected before a unnecessary memory reallocation is done.

* Use write instead of fwrite to write the result file

This avoids the caching in stdio where a write is split into two (at least on
my system): first a small 4k one and then one with the remaining 60k.
src/hash.cpp
src/hash.hpp
src/legacy_util.cpp
src/legacy_util.hpp
src/result.cpp