From 8665231f51564f1fb48f3148db6de4d982034c6c Mon Sep 17 00:00:00 2001 From: Ivan Maidanski Date: Sun, 1 May 2022 22:03:15 +0300 Subject: Simplify expression to clear extra bits in GC_add_ext_descriptor (refactoring) * typd_mlc.c (GC_add_ext_descriptor): Remove last_part and extra_bits local variables; improve comment regarding clearing extra bits; replace (x<>n expression to x&(GC_WORD_MAX>>n); compute ed_bitmap of the last element of GC_ext_descriptors directly (i.e., w/o intermediate variables). --- typd_mlc.c | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-) (limited to 'typd_mlc.c') diff --git a/typd_mlc.c b/typd_mlc.c index e66cdbe1..4c754c22 100644 --- a/typd_mlc.c +++ b/typd_mlc.c @@ -105,8 +105,6 @@ STATIC signed_word GC_add_ext_descriptor(const word * bm, word nbits) size_t nwords = divWORDSZ(nbits + WORDSZ-1); signed_word result; size_t i; - word last_part; - size_t extra_bits; DCL_LOCK_STATE; LOCK(); @@ -144,12 +142,9 @@ STATIC signed_word GC_add_ext_descriptor(const word * bm, word nbits) GC_ext_descriptors[result + i].ed_bitmap = bm[i]; GC_ext_descriptors[result + i].ed_continued = TRUE; } - last_part = bm[i]; - /* Clear irrelevant bits. */ - extra_bits = nwords * WORDSZ - nbits; - last_part <<= extra_bits; - last_part >>= extra_bits; - GC_ext_descriptors[result + i].ed_bitmap = last_part; + /* Clear irrelevant (highest) bits for the last element. */ + GC_ext_descriptors[result + i].ed_bitmap = + bm[i] & (GC_WORD_MAX >> (nwords * WORDSZ - nbits)); GC_ext_descriptors[result + i].ed_continued = FALSE; GC_avail_descr += nwords; UNLOCK(); -- cgit v1.2.1