diff options
author | Ivan Maidanski <ivmai@mail.ru> | 2022-05-01 22:03:15 +0300 |
---|---|---|
committer | Ivan Maidanski <ivmai@mail.ru> | 2022-05-01 22:03:15 +0300 |
commit | 8665231f51564f1fb48f3148db6de4d982034c6c (patch) | |
tree | cbce45fc5ba778b44a931ff00856a6dd877c6a7d /typd_mlc.c | |
parent | d833880a0f3cab314cd1f06a1a1bec5024cfdacd (diff) | |
download | bdwgc-8665231f51564f1fb48f3148db6de4d982034c6c.tar.gz |
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)>>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).
Diffstat (limited to 'typd_mlc.c')
-rw-r--r-- | typd_mlc.c | 11 |
1 files changed, 3 insertions, 8 deletions
@@ -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(); |