Skip to content

Commit 701d69f

Browse files
committed
Remove a useless sort and otherwise sort by offset, not line.
It is pointless to sort a list before converting it into a Set.
1 parent a55ee4d commit 701d69f

File tree

1 file changed

+9
-14
lines changed

1 file changed

+9
-14
lines changed

compiler/src/dotty/tools/dotc/transform/CheckUnused.scala

Lines changed: 9 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -290,7 +290,7 @@ class CheckUnused private (phaseMode: CheckUnused.PhaseMode, suffix: String, _ke
290290

291291
/** Do the actual reporting given the result of the anaylsis */
292292
private def reportUnused(res: UnusedData.UnusedResult)(using Context): Unit =
293-
res.warnings.toList.sortBy(_.pos.line)(using Ordering[Int]).foreach { s =>
293+
res.warnings.toList.sortBy(_.pos.span.point)(using Ordering[Int]).foreach { s =>
294294
s match
295295
case UnusedSymbol(t, _, WarnTypes.Imports) =>
296296
report.warning(s"unused import", t)
@@ -583,19 +583,14 @@ object CheckUnused:
583583
else
584584
Nil
585585
val warnings =
586-
val unsorted =
587-
sortedImp :::
588-
sortedLocalDefs :::
589-
sortedExplicitParams :::
590-
sortedImplicitParams :::
591-
sortedPrivateDefs :::
592-
sortedPatVars :::
593-
unsetLocalDefs :::
594-
unsetPrivateDefs
595-
unsorted.sortBy { s =>
596-
val pos = s.pos.sourcePos
597-
(pos.line, pos.column)
598-
}
586+
sortedImp :::
587+
sortedLocalDefs :::
588+
sortedExplicitParams :::
589+
sortedImplicitParams :::
590+
sortedPrivateDefs :::
591+
sortedPatVars :::
592+
unsetLocalDefs :::
593+
unsetPrivateDefs
599594
UnusedResult(warnings.toSet)
600595
end getUnused
601596
//============================ HELPERS ====================================

0 commit comments

Comments
 (0)