object-file: treat cached_object values as const
The cached-object API maps oids to in-memory entries. Once inserted, these entries should be immutable. Let's return them from the find_cached_object() call with a const tag to make this clear. Suggested-by: Patrick Steinhardt <ps@pks.im> Signed-off-by: Jeff King <peff@peff.net> Signed-off-by: Junio C Hamano <gitster@pobox.com>
This commit is contained in:

committed by
Junio C Hamano

parent
9202ffcf10
commit
e37feea00b
@ -327,14 +327,14 @@ static struct cached_object_entry {
|
|||||||
} *cached_objects;
|
} *cached_objects;
|
||||||
static int cached_object_nr, cached_object_alloc;
|
static int cached_object_nr, cached_object_alloc;
|
||||||
|
|
||||||
static struct cached_object *find_cached_object(const struct object_id *oid)
|
static const struct cached_object *find_cached_object(const struct object_id *oid)
|
||||||
{
|
{
|
||||||
static struct cached_object empty_tree = {
|
static const struct cached_object empty_tree = {
|
||||||
.type = OBJ_TREE,
|
.type = OBJ_TREE,
|
||||||
.buf = "",
|
.buf = "",
|
||||||
};
|
};
|
||||||
int i;
|
int i;
|
||||||
struct cached_object_entry *co = cached_objects;
|
const struct cached_object_entry *co = cached_objects;
|
||||||
|
|
||||||
for (i = 0; i < cached_object_nr; i++, co++) {
|
for (i = 0; i < cached_object_nr; i++, co++) {
|
||||||
if (oideq(&co->oid, oid))
|
if (oideq(&co->oid, oid))
|
||||||
@ -1629,7 +1629,7 @@ static int do_oid_object_info_extended(struct repository *r,
|
|||||||
struct object_info *oi, unsigned flags)
|
struct object_info *oi, unsigned flags)
|
||||||
{
|
{
|
||||||
static struct object_info blank_oi = OBJECT_INFO_INIT;
|
static struct object_info blank_oi = OBJECT_INFO_INIT;
|
||||||
struct cached_object *co;
|
const struct cached_object *co;
|
||||||
struct pack_entry e;
|
struct pack_entry e;
|
||||||
int rtype;
|
int rtype;
|
||||||
const struct object_id *real = oid;
|
const struct object_id *real = oid;
|
||||||
|
Reference in New Issue
Block a user