More QOL updates

This commit is contained in:
zontreck 2024-05-07 04:29:48 -07:00
parent 9b7b84153f
commit 7d75a2b5f8
2 changed files with 10 additions and 16 deletions

View file

@ -344,7 +344,8 @@ class ByteLayer {
_position = position; _position = position;
} }
void waitSetBit(int position, int maskToClear, int maskToSet) { /// Unsets a mask, then sets a mask
void unsetSetBit(int position, int maskToClear, int maskToSet) {
clearBit(position, maskToClear); clearBit(position, maskToClear);
setBit(position, maskToSet); setBit(position, maskToSet);

View file

@ -9,15 +9,8 @@ class UUID {
late final int MSB; late final int MSB;
UUID(int msb, int lsb) { UUID(int msb, int lsb) {
if (msb < 0) MSB = msb.abs();
MSB = -msb; LSB = lsb.abs();
else
MSB = msb;
if (lsb < 0)
LSB = -lsb;
else
LSB = lsb;
} }
static final UUID ZERO = UUID.generate(0); static final UUID ZERO = UUID.generate(0);
@ -100,8 +93,8 @@ class UUID {
layer.clear(); layer.clear();
layer.writeBytes(bytes); layer.writeBytes(bytes);
layer.waitSetBit(6, 0x0F, 0x30); layer.unsetSetBit(6, 0x0F, 0x30);
layer.waitSetBit(8, 0x3F, 0x80); layer.unsetSetBit(8, 0x3F, 0x80);
layer.resetPosition(); layer.resetPosition();
@ -117,8 +110,8 @@ class UUID {
layer.writeLong( layer.writeLong(
(random.nextInt(0xFFFFFFFF) << 32) | random.nextInt(0xFFFFFFFF)); (random.nextInt(0xFFFFFFFF) << 32) | random.nextInt(0xFFFFFFFF));
layer.waitSetBit(6, 0x0F, 0x40); layer.unsetSetBit(6, 0x0F, 0x40);
layer.waitSetBit(8, 0x3F, 0x80); layer.unsetSetBit(8, 0x3F, 0x80);
layer.resetPosition(); layer.resetPosition();
@ -147,8 +140,8 @@ class UUID {
layer.clear(); layer.clear();
layer.writeBytes(hashBytes); layer.writeBytes(hashBytes);
layer.waitSetBit(6, 0x0F, 0x50); layer.unsetSetBit(6, 0x0F, 0x50);
layer.waitSetBit(8, 0x3F, 0x80); layer.unsetSetBit(8, 0x3F, 0x80);
layer.resetPosition(); layer.resetPosition();