Skip to content

Commit 9883fcb

Browse files
committed
Merge branch 'ty/patch-ids-document-lazy-eval'
In-code comment update to record a design decision to allow lazy computation of patch IDs. * ty/patch-ids-document-lazy-eval: patch-ids: document intentional const-casting in patch_id_neq()
2 parents 3c59f3b + 4c22357 commit 9883fcb

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

patch-ids.c

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,14 @@ static int patch_id_neq(const void *cmpfn_data,
4141
const struct hashmap_entry *entry_or_key,
4242
const void *keydata UNUSED)
4343
{
44-
/* NEEDSWORK: const correctness? */
44+
/*
45+
* We drop the 'const' modifier here intentionally.
46+
*
47+
* Even though eptr and entry_or_key are const, we want to
48+
* lazily compute their .patch_id members; see b3dfeebb (rebase:
49+
* avoid computing unnecessary patch IDs, 2016-07-29). So we cast
50+
* the constness away with container_of().
51+
*/
4552
struct diff_options *opt = (void *)cmpfn_data;
4653
struct patch_id *a, *b;
4754

0 commit comments

Comments
 (0)