Skip to content

Commit

Permalink
[ELF] Refactor
Browse files Browse the repository at this point in the history
  • Loading branch information
rui314 committed Sep 29, 2021
1 parent a2c9d0a commit aa30c4e
Showing 1 changed file with 9 additions and 7 deletions.
16 changes: 9 additions & 7 deletions mold.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;
};

Expand All @@ -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:
Expand Down

0 comments on commit aa30c4e

Please sign in to comment.