[2.x] refactor: Remove redundant conversions (#8786)

This commit is contained in:
kenji yoshida 2026-02-23 13:44:17 +09:00 committed by GitHub
parent 20f4a9c3b2
commit 62e43711f2
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
10 changed files with 16 additions and 17 deletions

View File

@ -236,7 +236,7 @@ object Logic {
}
private def keepPositive(lits: Set[Literal]): Set[Atom] =
lits.collect { case a: Atom => a }.toSet
lits.collect { case a: Atom => a }
// precondition: factsToProcess contains no contradictions
@tailrec private def reduce0(

View File

@ -154,7 +154,7 @@ private[internal] object SbtUpdateReport {
val deps = classifiersOpt match {
case Some(classifiers) =>
res.dependencyArtifacts(Some(classifiers.toSeq), classpathOrder)
res.dependencyArtifacts(Some(classifiers), classpathOrder)
case None =>
res.dependencyArtifacts(None, classpathOrder)
}

View File

@ -220,7 +220,7 @@ private[sbt] class CachedResolutionResolveCache {
else if (dynamicGraphPath.exists) Some(dynamicGraphPath)
else None) match {
case Some(path) =>
log.debug(s"parsing ${path.getAbsolutePath.toString}")
log.debug(s"parsing ${path.getAbsolutePath}")
val ur = JsonUtil.parseUpdateReport(path, cachedDescriptor, log)
if (ur.allFiles forall { _.exists }) {
updateReportCache(md.getModuleRevisionId) = Right(ur)
@ -568,7 +568,7 @@ private[sbt] trait CachedResolutionResolveEngine extends ResolveEngine {
): Vector[OrganizationArtifactReport] = {
// filter out evicted modules from further logic
def filterReports(report0: OrganizationArtifactReport): Option[OrganizationArtifactReport] =
report0.modules.toVector flatMap { mr =>
report0.modules flatMap { mr =>
if (mr.evicted || mr.problem.nonEmpty) None
else
// https://github.com/sbt/sbt/issues/1763
@ -980,7 +980,7 @@ private[sbt] trait CachedResolutionResolveEngine extends ResolveEngine {
}
// These are the configurations from the original project we want to resolve.
val rootModuleConfs = md0.getConfigurations.toVector
val configurations0: Vector[ConfigurationReport] = ur.configurations.toVector
val configurations0: Vector[ConfigurationReport] = ur.configurations
// This is how md looks from md0 via dd's mapping.
val remappedConfigs0: Map[String, Vector[String]] = Map(rootModuleConfs map { conf0 =>
val remapped: Vector[String] = dd

View File

@ -3703,7 +3703,7 @@ object Classpaths {
// https://github.com/sbt/sbt/issues/4408
val xs = (explicit, boot) match {
case (Some(ex), Some(b)) => (ex.toVector ++ b.toVector).distinct
case (Some(ex), None) => ex.toVector
case (Some(ex), None) => ex
case (None, Some(b)) => b.toVector
case _ => Vector()
}

View File

@ -592,7 +592,7 @@ object ProjectMatrix {
jsPlatform(scalaVersions, Nil)
override def defaultAxes(axes: VirtualAxis*): ProjectMatrix =
copy(defAxes = axes.toSeq)
copy(defAxes = axes)
def scalajsPlugin: Try[AutoPlugin] = {
import ReflectionUtil.*
@ -775,7 +775,7 @@ object ProjectMatrix {
customRow(autoScalaLibrary, crossVersion = None, scalaVersions, axisValues)(process)
override def finder(axisValues: VirtualAxis*): ProjectFinder =
new AxisBaseProjectFinder(axisValues.toSeq)
new AxisBaseProjectFinder(axisValues)
override def allProjects(): Seq[(Project, Seq[VirtualAxis])] =
resolvedMappings.map { (row, project) =>

View File

@ -138,8 +138,8 @@ private[sbt] final class AKeyIndex(val data: Relation[Option[AttributeKey[?]], S
def add(task: Option[AttributeKey[?]], key: AttributeKey[?]): AKeyIndex =
new AKeyIndex(data + (task, key.label))
def keys(task: Option[AttributeKey[?]]): Set[String] = data.forward(task)
def allKeys: Set[String] = data._2s.toSet
def tasks: Set[AttributeKey[?]] = data._1s.flatten.toSet
def allKeys: Set[String] = data._2s
def tasks: Set[AttributeKey[?]] = data._1s.flatten
def tasks(key: String): Set[AttributeKey[?]] = data.reverse(key).flatten
}

View File

@ -756,7 +756,7 @@ private[sbt] object LibraryManagement {
val tmpFile = File.createTempFile("checksum", suffix)
IO.write(tmpFile, content)
(tmpFile, suffix)
}.toVector
}
artifacts.foreach { case (artifact, sourceFile) =>
val folder = typeToFolder(artifact.`type`)
@ -903,7 +903,6 @@ private[sbt] object LibraryManagement {
val tmpFile = File.createTempFile("checksum", suffix)
IO.write(tmpFile, content)
(tmpFile, suffix)
.toVector
val base = baseUrl.stripSuffix("/") + "/"
artifacts.foreach:

View File

@ -86,7 +86,7 @@ object DependencyLockManager:
extension = artifact.extension,
tpe = artifact.`type`
)
}.toVector
}
DependencyLock(
organization = moduleReport.module.organization,
@ -98,13 +98,13 @@ object DependencyLockManager:
transitives = Vector.empty,
artifacts = artifacts
)
}.toVector
}
ConfigurationLock(
name = configReport.configuration.name,
dependencies = deps
)
}.toVector
}
val metadata = LockFileMetadata(
sbtVersion = sbtVersion,

View File

@ -242,7 +242,7 @@ object BuildServerProtocol {
workspace.warnIfBuildsNonEmpty(Method.ScalaTestClasses, s.log)
val items = bspScalaTestClassesItem.result.all(filter).value
val successfulItems = anyOrThrow(items).flatten.toVector
val result = ScalaTestClassesResult(successfulItems.toVector, None)
val result = ScalaTestClassesResult(successfulItems, None)
s.respondEvent(result)
}.evaluated,
bspBuildTargetJVMRunEnvironment / aggregate := false,

View File

@ -27,7 +27,7 @@ object ConfigLoader:
val fromConfigLines = loadLines(fromConfig)
val fromEtcLines = loadLines(fromEtc)
val fromSbtConfigLines = loadLines(fromSbtConfig)
(fromEtcLines ++ fromConfigLines ++ fromSbtConfigLines ++ fromEnv ++ fromProjectLines).toSeq
(fromEtcLines ++ fromConfigLines ++ fromSbtConfigLines ++ fromEnv ++ fromProjectLines)
def loadJvmOpts(cwd: File): Seq[String] =
val fromProject = new File(cwd, ".jvmopts")