Skip to content

Commit aa30c4e

Browse files
committed
[ELF] Refactor
1 parent a2c9d0a commit aa30c4e

File tree

1 file changed

+9
-7
lines changed

1 file changed

+9
-7
lines changed

mold.h

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -329,22 +329,24 @@ class ConcurrentMap {
329329
//
330330

331331
class BitVector {
332-
struct BitRef {
333-
BitRef(u8 &byte, u8 bitpos) : byte(byte), bitpos(bitpos) {}
332+
class BitRef {
333+
public:
334+
BitRef(u8 *byte, u8 bitpos) : byte(byte), bitpos(bitpos) {}
334335

335336
BitRef &operator=(bool val) {
336337
if (val)
337-
byte |= (1 << bitpos);
338+
*byte |= (1 << bitpos);
338339
else
339-
byte &= ~(1 << bitpos);
340+
*byte &= ~(1 << bitpos);
340341
return *this;
341342
}
342343

343344
operator bool() const {
344-
return byte & (1 << bitpos);
345+
return *byte & (1 << bitpos);
345346
}
346347

347-
u8 &byte;
348+
private:
349+
u8 *byte;
348350
u8 bitpos;
349351
};
350352

@@ -355,7 +357,7 @@ class BitVector {
355357
}
356358

357359
BitRef operator[](i64 i) {
358-
return BitRef(vec[i / 8], i % 8);
360+
return BitRef(&vec[i / 8], i % 8);
359361
}
360362

361363
private:

0 commit comments

Comments
 (0)