Skip to content

Commit 96bea13

Browse files
committed
Use BitSet for boolean TASTy attributes
1 parent e7f8a2c commit 96bea13

File tree

3 files changed

+10
-4
lines changed

3 files changed

+10
-4
lines changed

compiler/src/dotty/tools/dotc/core/tasty/AttributeUnpickler.scala

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,15 @@ package dotty.tools.dotc
22
package core.tasty
33

44
import scala.language.unsafeNulls
5+
import scala.collection.immutable.BitSet
56

67
import dotty.tools.tasty.{TastyFormat, TastyReader, TastyBuffer}
78

89
class AttributeUnpickler(reader: TastyReader):
910
import reader._
1011

1112
lazy val attributes: Attributes = {
12-
val booleanTags = List.newBuilder[Int]
13+
val booleanTags = BitSet.newBuilder
1314

1415
while !isAtEnd do
1516
booleanTags += readByte()

compiler/src/dotty/tools/dotc/core/tasty/Attributes.scala

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,10 @@ package dotty.tools.dotc.core.tasty
22

33
import dotty.tools.tasty.TastyFormat
44

5+
import scala.collection.immutable.BitSet
6+
57
class Attributes(
6-
val booleanTags: List[Int],
8+
val booleanTags: BitSet,
79
) {
810
def scala2StandardLibrary: Boolean =
911
booleanTags.contains(TastyFormat.SCALA2STANDARDLIBRARYattr)
@@ -16,8 +18,11 @@ object Attributes:
1618
scala2StandardLibrary: Boolean,
1719
explicitNulls: Boolean,
1820
): Attributes =
19-
val booleanTags = List.newBuilder[Int]
21+
val booleanTags = BitSet.newBuilder
2022
if scala2StandardLibrary then booleanTags += TastyFormat.SCALA2STANDARDLIBRARYattr
2123
if explicitNulls then booleanTags += TastyFormat.EXPLICITNULLSattr
2224
new Attributes(booleanTags.result())
2325
end apply
26+
27+
def empty: Attributes =
28+
new Attributes(BitSet.empty)

compiler/src/dotty/tools/dotc/core/tasty/DottyUnpickler.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ class DottyUnpickler(bytes: Array[Byte], mode: UnpickleMode = UnpickleMode.TopLe
5757
private val treeUnpickler = unpickler.unpickle(treeSectionUnpickler(posUnpicklerOpt, commentUnpicklerOpt, attributeUnpicklerOpt)).get
5858

5959
def tastyAttributes: Attributes =
60-
attributeUnpicklerOpt.map(_.attributes).getOrElse(new Attributes(booleanTags = Nil))
60+
attributeUnpicklerOpt.map(_.attributes).getOrElse(Attributes.empty)
6161

6262
/** Enter all toplevel classes and objects into their scopes
6363
* @param roots a set of SymDenotations that should be overwritten by unpickling

0 commit comments

Comments
 (0)