Skip to content

Commit ba0ade9

Browse files
committed
Move off SimpleMap
1 parent 2fa1738 commit ba0ade9

File tree

4 files changed

+18
-21
lines changed

4 files changed

+18
-21
lines changed

compiler/src/dotty/tools/dotc/core/Names.scala

Lines changed: 8 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,8 @@ import StdNames.str
1212
import Designators._
1313
import util.Chars.isIdentifierStart
1414
import collection.IndexedSeqOptimized
15-
import collection.generic.CanBuildFrom
16-
import collection.mutable.{ Builder, StringBuilder, AnyRefMap }
17-
import collection.immutable.WrappedString
18-
import collection.generic.CanBuildFrom
19-
import util.{DotClass, SimpleMap}
15+
import collection.immutable
16+
import util.{DotClass}
2017
import config.Config
2118
import java.util.HashMap
2219

@@ -193,24 +190,24 @@ object Names {
193190
def underlying: TermName = unsupported("underlying")
194191

195192
@sharable // because of synchronized block in `and`
196-
private var derivedNames: AnyRef /* SimpleMap | j.u.HashMap */ =
197-
SimpleMap.Empty[NameInfo]
193+
private var derivedNames: AnyRef /* immutable.Map[NameInfo, DerivedName] | j.u.HashMap */ =
194+
immutable.Map.empty[NameInfo, DerivedName]
198195

199196
private def getDerived(info: NameInfo): DerivedName /* | Null */= derivedNames match {
200-
case derivedNames: SimpleMap[NameInfo, DerivedName] @unchecked =>
201-
derivedNames(info)
197+
case derivedNames: immutable.AbstractMap[NameInfo, DerivedName] @unchecked =>
198+
if (derivedNames.contains(info)) derivedNames(info) else null
202199
case derivedNames: HashMap[NameInfo, DerivedName] @unchecked =>
203200
derivedNames.get(info)
204201
}
205202

206203
private def putDerived(info: NameInfo, name: DerivedName): name.type = {
207204
derivedNames match {
208-
case derivedNames: SimpleMap[NameInfo, DerivedName] @unchecked =>
205+
case derivedNames: immutable.Map[NameInfo, DerivedName] @unchecked =>
209206
if (derivedNames.size < 4)
210207
this.derivedNames = derivedNames.updated(info, name)
211208
else {
212209
val newMap = new HashMap[NameInfo, DerivedName]
213-
derivedNames.foreachBinding(newMap.put(_, _))
210+
derivedNames.foreach { case (k, v) => newMap.put(k, v) }
214211
newMap.put(info, name)
215212
this.derivedNames = newMap
216213
}

compiler/src/dotty/tools/dotc/typer/ImportInfo.scala

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import ast.{tpd, untpd}
66
import ast.Trees._
77
import core._
88
import printing.{Printer, Showable}
9-
import util.SimpleMap
9+
import util.SimpleEqMap
1010
import Symbols._, Names._, Denotations._, Types._, Contexts._, StdNames._, Flags._
1111
import Decorators.StringInterpolators
1212

@@ -52,7 +52,7 @@ class ImportInfo(symf: Context => Symbol, val selectors: List[untpd.Tree],
5252
def excluded: Set[TermName] = { ensureInitialized(); myExcluded }
5353

5454
/** A mapping from renamed to original names */
55-
def reverseMapping: SimpleMap[TermName, TermName] = { ensureInitialized(); myMapped }
55+
def reverseMapping: SimpleEqMap[TermName, TermName] = { ensureInitialized(); myMapped }
5656

5757
/** The original names imported by-name before renaming */
5858
def originals: Set[TermName] = { ensureInitialized(); myOriginals }
@@ -61,14 +61,14 @@ class ImportInfo(symf: Context => Symbol, val selectors: List[untpd.Tree],
6161
def isWildcardImport = { ensureInitialized(); myWildcardImport }
6262

6363
private var myExcluded: Set[TermName] = null
64-
private var myMapped: SimpleMap[TermName, TermName] = null
64+
private var myMapped: SimpleEqMap[TermName, TermName] = null
6565
private var myOriginals: Set[TermName] = null
6666
private var myWildcardImport: Boolean = false
6767

6868
/** Compute info relating to the selector list */
6969
private def ensureInitialized(): Unit = if (myExcluded == null) {
7070
myExcluded = Set()
71-
myMapped = SimpleMap.Empty
71+
myMapped = SimpleEqMap.Empty
7272
myOriginals = Set()
7373
def recur(sels: List[untpd.Tree]): Unit = sels match {
7474
case sel :: sels1 =>

compiler/src/dotty/tools/dotc/typer/Inferencing.scala

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ import Scopes._
1111
import ProtoTypes._
1212
import annotation.unchecked
1313
import util.Positions._
14-
import util.{Stats, SimpleMap}
14+
import util.{Stats, SimpleEqMap}
1515
import util.common._
1616
import Decorators._
1717
import Uniques._
@@ -286,7 +286,7 @@ object Inferencing {
286286
result
287287
}
288288

289-
type VarianceMap = SimpleMap[TypeVar, Integer]
289+
type VarianceMap = SimpleEqMap[TypeVar, Integer]
290290

291291
/** All occurrences of type vars in this type that satisfy predicate
292292
* `include` mapped to their variances (-1/0/1) in this type, where
@@ -350,7 +350,7 @@ object Inferencing {
350350
if (vmap1 eq vmap) vmap else propagate(vmap1)
351351
}
352352

353-
propagate(accu(SimpleMap.Empty, tp))
353+
propagate(accu(SimpleEqMap.Empty, tp))
354354
}
355355
}
356356

compiler/src/dotty/tools/dotc/typer/ProtoTypes.scala

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ import Constants._
1111
import Scopes._
1212
import annotation.unchecked
1313
import util.Positions._
14-
import util.{Stats, SimpleMap}
14+
import util.{Stats, SimpleEqMap}
1515
import util.common._
1616
import Decorators._
1717
import Uniques._
@@ -179,10 +179,10 @@ object ProtoTypes {
179179
override def resultType(implicit ctx: Context) = resType
180180

181181
/** A map in which typed arguments can be stored to be later integrated in `typedArgs`. */
182-
private var myTypedArg: SimpleMap[untpd.Tree, Tree] = SimpleMap.Empty
182+
private var myTypedArg: SimpleEqMap[untpd.Tree, Tree] = SimpleEqMap.Empty
183183

184184
/** A map recording the typer states in which arguments stored in myTypedArg were typed */
185-
private var evalState: SimpleMap[untpd.Tree, TyperState] = SimpleMap.Empty
185+
private var evalState: SimpleEqMap[untpd.Tree, TyperState] = SimpleEqMap.Empty
186186

187187
def isMatchedBy(tp: Type)(implicit ctx: Context) =
188188
typer.isApplicable(tp, Nil, typedArgs, resultType)

0 commit comments

Comments
 (0)