Skip to content

Commit 6df2406

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 4b1cf4f commit 6df2406

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
@@ -289,7 +289,7 @@ class CheckUnused private (phaseMode: CheckUnused.PhaseMode, suffix: String, _ke
289289

290290
/** Do the actual reporting given the result of the anaylsis */
291291
private def reportUnused(res: UnusedData.UnusedResult)(using Context): Unit =
292-
res.warnings.toList.sortBy(_.pos.line)(using Ordering[Int]).foreach { s =>
292+
res.warnings.toList.sortBy(_.pos.span.point)(using Ordering[Int]).foreach { s =>
293293
s match
294294
case UnusedSymbol(t, _, WarnTypes.Imports) =>
295295
report.warning(s"unused import", t)
@@ -580,19 +580,14 @@ object CheckUnused:
580580
else
581581
Nil
582582
val warnings =
583-
val unsorted =
584-
sortedImp :::
585-
sortedLocalDefs :::
586-
sortedExplicitParams :::
587-
sortedImplicitParams :::
588-
sortedPrivateDefs :::
589-
sortedPatVars :::
590-
unsetLocalDefs :::
591-
unsetPrivateDefs
592-
unsorted.sortBy { s =>
593-
val pos = s.pos.sourcePos
594-
(pos.line, pos.column)
595-
}
583+
sortedImp :::
584+
sortedLocalDefs :::
585+
sortedExplicitParams :::
586+
sortedImplicitParams :::
587+
sortedPrivateDefs :::
588+
sortedPatVars :::
589+
unsetLocalDefs :::
590+
unsetPrivateDefs
596591
UnusedResult(warnings.toSet)
597592
end getUnused
598593
//============================ HELPERS ====================================

0 commit comments

Comments
 (0)