From aa30c4ef2c0b34a466df961f5ccca4e1639682dd Mon Sep 17 00:00:00 2001 From: Rui Ueyama Date: Wed, 29 Sep 2021 23:58:34 +0900 Subject: [PATCH] [ELF] Refactor --- mold.h | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/mold.h b/mold.h index 27a54927a2..875e6624ce 100644 --- a/mold.h +++ b/mold.h @@ -329,22 +329,24 @@ class ConcurrentMap { // class BitVector { - struct BitRef { - BitRef(u8 &byte, u8 bitpos) : byte(byte), bitpos(bitpos) {} + class BitRef { + public: + BitRef(u8 *byte, u8 bitpos) : byte(byte), bitpos(bitpos) {} BitRef &operator=(bool val) { if (val) - byte |= (1 << bitpos); + *byte |= (1 << bitpos); else - byte &= ~(1 << bitpos); + *byte &= ~(1 << bitpos); return *this; } operator bool() const { - return byte & (1 << bitpos); + return *byte & (1 << bitpos); } - u8 &byte; + private: + u8 *byte; u8 bitpos; }; @@ -355,7 +357,7 @@ class BitVector { } BitRef operator[](i64 i) { - return BitRef(vec[i / 8], i % 8); + return BitRef(&vec[i / 8], i % 8); } private: