mirror of
https://github.com/git-for-windows/git.git
synced 2026-04-10 16:54:08 -05:00
odb: fix unnecessary call to find_cached_object()
The function `odb_pretend_object()` writes an object into the in-memory object database source. The effect of this is that the object will now become readable, but it won't ever be persisted to disk. Before storing the object, we first verify whether the object already exists. This is done by calling `odb_has_object()` to check all sources, followed by `find_cached_object()` to check whether we have already stored the object in our in-memory source. This is unnecessary though, as `odb_has_object()` already checks the in-memory source transitively via: - `odb_has_object()` - `odb_read_object_info_extended()` - `do_oid_object_info_extended()` - `find_cached_object()` Drop the explicit call to `find_cached_object()`. Signed-off-by: Patrick Steinhardt <ps@pks.im> Signed-off-by: Junio C Hamano <gitster@pobox.com>
This commit is contained in:
committed by
Junio C Hamano
parent
06e49d9d29
commit
0e06dbdd14
3
odb.c
3
odb.c
@@ -774,8 +774,7 @@ int odb_pretend_object(struct object_database *odb,
|
||||
char *co_buf;
|
||||
|
||||
hash_object_file(odb->repo->hash_algo, buf, len, type, oid);
|
||||
if (odb_has_object(odb, oid, 0) ||
|
||||
find_cached_object(odb, oid))
|
||||
if (odb_has_object(odb, oid, 0))
|
||||
return 0;
|
||||
|
||||
ALLOC_GROW(odb->inmemory_objects->objects,
|
||||
|
||||
Reference in New Issue
Block a user