mirror of
https://git.proxmox.com/git/libgit2
synced 2025-05-29 18:38:58 +00:00
git_futils_readbuffer: don't compute sha-1
Don't compute the sha-1 in `git_futils_readbuffer_updated` unless the checksum was requested. This means that `git_futils_readbuffer` will not calculate the checksum unnecessarily.
This commit is contained in:
parent
b31b236004
commit
11c8e756ac
@ -196,6 +196,7 @@ int git_futils_readbuffer_updated(
|
||||
|
||||
p_close(fd);
|
||||
|
||||
if (checksum) {
|
||||
if ((error = git_hash_buf(&checksum_new, buf.ptr, buf.size)) < 0) {
|
||||
git_buf_free(&buf);
|
||||
return error;
|
||||
@ -204,7 +205,7 @@ int git_futils_readbuffer_updated(
|
||||
/*
|
||||
* If we were given a checksum, we only want to use it if it's different
|
||||
*/
|
||||
if (checksum && !git_oid__cmp(checksum, &checksum_new)) {
|
||||
if (!git_oid__cmp(checksum, &checksum_new)) {
|
||||
git_buf_free(&buf);
|
||||
if (updated)
|
||||
*updated = 0;
|
||||
@ -212,12 +213,12 @@ int git_futils_readbuffer_updated(
|
||||
return 0;
|
||||
}
|
||||
|
||||
git_oid_cpy(checksum, &checksum_new);
|
||||
}
|
||||
|
||||
/*
|
||||
* If we're here, the file did change, or the user didn't have an old version
|
||||
*/
|
||||
if (checksum)
|
||||
git_oid_cpy(checksum, &checksum_new);
|
||||
|
||||
if (updated != NULL)
|
||||
*updated = 1;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user