Skip to content

Commit

Permalink
Merge pull request #1421 from xuwei-k/filterKeys-mapValues
Browse files Browse the repository at this point in the history
  • Loading branch information
eed3si9n authored Oct 3, 2024
2 parents 141fb2d + 332afec commit 21f6ee8
Show file tree
Hide file tree
Showing 5 changed files with 9 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ private class MAPIs(
def removeInternal(removeClasses: Iterable[String]): APIs =
new MAPIs(internal -- removeClasses, external)
def filterExt(keep: String => Boolean): APIs =
new MAPIs(internal, external.filterKeys(keep).toMap)
new MAPIs(internal, external.view.filterKeys(keep).toMap)

def internalAPI(className: String) = getAPI(internal, className)
def externalAPI(ext: String) = getAPI(external, ext)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -352,13 +352,13 @@ private class MStamps(
lib: VirtualFileRef => Boolean
): Stamps =
new MStamps(
products.filterKeys(prod).toMap, {
products.view.filterKeys(prod).toMap, {
val rs = removeSources.toSet
Map(sources.toSeq.filter {
case (file, stamp) => !rs(file)
}: _*)
},
libraries.filterKeys(lib).toMap
libraries.view.filterKeys(lib).toMap
)

def groupBy[K](
Expand All @@ -370,9 +370,9 @@ private class MStamps(

val constFalse = (f: VirtualFileRef) => false
def kStamps(k: K): Stamps = new MStamps(
products.filterKeys(prod.getOrElse(k, constFalse)).toMap,
products.view.filterKeys(prod.getOrElse(k, constFalse)).toMap,
sourcesMap.getOrElse(k, Map.empty[VirtualFileRef, XStamp]),
libraries.filterKeys(lib.getOrElse(k, constFalse)).toMap
libraries.view.filterKeys(lib.getOrElse(k, constFalse)).toMap
)

(for (k <- prod.keySet ++ sourcesMap.keySet ++ lib.keySet) yield (k, kStamps(k))).toMap
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,7 @@ class ConsistentAnalysisFormat(val mappers: ReadWriteMappers, sort: Boolean) {
writeMaybeSortedStringMap(
out,
n,
m.mapValues(_.withCompilationTimestamp(DefaultCompilationTimestamp))
m.view.mapValues(_.withCompilationTimestamp(DefaultCompilationTimestamp))
) { ac =>
writeAnalyzedClass(out, ac, storeApis)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@ object AnalysisGenerators {
val genFileVORefRelation = genVirtualFileRefRelation(unique(genFileVRef)) _

def rel[A, B](a: Seq[A], b: Seq[B]): Relation[A, B] =
Relation.reconstruct(zipMap(a, b).mapValues(Set(_)).toMap)
Relation.reconstruct(zipMap(a, b).view.mapValues(Set(_)).toMap)

def genStringStringRelation(num: Int): Gen[Relation[String, String]] =
for {
Expand Down
4 changes: 2 additions & 2 deletions internal/zinc-testing/src/main/scala/xsbti/TestCallback.scala
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ class TestCallback extends AnalysisCallback2 {
val apis: scala.collection.mutable.Map[VirtualFileRef, Set[ClassLike]] =
scala.collection.mutable.Map.empty

def usedNames = usedNamesAndScopes.mapValues(_.map(_.name))
def usedNames = usedNamesAndScopes.view.mapValues(_.map(_.name))

override def startSource(source: File): Unit = ???
override def startSource(source: VirtualFile): Unit = {
Expand Down Expand Up @@ -182,7 +182,7 @@ object TestCallback {
acc.addBinding(key, value)
}
// convert all collections to immutable variants
multiMap.toMap.mapValues(_.toSet).toMap.withDefaultValue(Set.empty)
multiMap.toMap.view.mapValues(_.toSet).toMap.withDefaultValue(Set.empty)
}
}
}

0 comments on commit 21f6ee8

Please sign in to comment.