Used cached compiled map in LintUnused

Linting unused keys was adding a significant overhead to sbt project
loading because Def.compiled is so slow. It was around 4 seconds in the
sbt project on my computer.
This commit is contained in:
Ethan Atkins 2020-07-03 11:55:52 -07:00
parent 6565618a15
commit 4a8e7c0734
1 changed files with 1 additions and 3 deletions

View File

@ -117,9 +117,7 @@ object LintUnused {
val extracted = Project.extract(state)
val structure = extracted.structure
val display = Def.showShortKey(None) // extracted.showKey
val actual = true
val comp =
Def.compiled(structure.settings, actual)(structure.delegates, structure.scopeLocal, display)
val comp = structure.compiledMap
val cMap = Def.flattenLocals(comp)
val used: Set[ScopedKey[_]] = cMap.values.flatMap(_.dependencies).toSet
val unused: Seq[ScopedKey[_]] = cMap.keys.filter(!used.contains(_)).toSeq