Skip to content

Commit

Permalink
Update DefaultMutableByteSet and DefaultMutableBooleanSet
Browse files Browse the repository at this point in the history
  • Loading branch information
Glavo committed Jul 7, 2024
1 parent 18f5ba4 commit a600267
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 34 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,12 @@
import org.jetbrains.annotations.Contract;
import org.jetbrains.annotations.NotNull;

import java.io.Serial;
import java.io.Serializable;

@SuppressWarnings("PointlessBooleanExpression")
final class DefaultMutableBooleanSet extends AbstractMutableBooleanSet implements Serializable {
@Serial
private static final long serialVersionUID = 0L;

private static final Factory FACTORY = new Factory();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,10 @@
import org.jetbrains.annotations.Contract;
import org.jetbrains.annotations.NotNull;

import java.io.Serial;

final class DefaultMutableByteSet extends AbstractDefaultByteSet implements MutableByteSet {
@Serial
private static final long serialVersionUID = 6028841354144450491L;

private static final Factory FACTORY = new Factory();
Expand Down Expand Up @@ -122,23 +125,13 @@ public boolean add(byte value) {
int bitsNumber = v / Long.SIZE;
int bitOffset = v % Long.SIZE;

long bits;
switch (bitsNumber) {
case 0:
bits = bits0;
break;
case 1:
bits = bits1;
break;
case 2:
bits = bits2;
break;
case 3:
bits = bits3;
break;
default:
throw new AssertionError();
}
long bits = switch (bitsNumber) {
case 0 -> bits0;
case 1 -> bits1;
case 2 -> bits2;
case 3 -> bits3;
default -> throw new AssertionError();
};

long newBits = bits | (1L << bitOffset);

Expand Down Expand Up @@ -173,23 +166,13 @@ public boolean remove(byte value) {
int bitsNumber = v / Long.SIZE;
int bitOffset = v % Long.SIZE;

long bits;
switch (bitsNumber) {
case 0:
bits = bits0;
break;
case 1:
bits = bits1;
break;
case 2:
bits = bits2;
break;
case 3:
bits = bits3;
break;
default:
throw new AssertionError();
}
long bits = switch (bitsNumber) {
case 0 -> bits0;
case 1 -> bits1;
case 2 -> bits2;
case 3 -> bits3;
default -> throw new AssertionError();
};

long newBits = bits & ~(1L << bitOffset);

Expand Down

0 comments on commit a600267

Please sign in to comment.