Skip to content

Commit 1bc354e

Browse files
committed
Code refactoring
1 parent b5ce7fe commit 1bc354e

File tree

1 file changed

+3
-6
lines changed
  • compiler/src/dotty/tools/dotc/transform/patmat

1 file changed

+3
-6
lines changed

compiler/src/dotty/tools/dotc/transform/patmat/Space.scala

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -132,20 +132,17 @@ trait SpaceLogic {
132132

133133
/** Remove a space if it's a subspace of remaining spaces
134134
*
135-
* Note: `dedup` will return the same result if the sequence > 10
135+
* Note: `dedup` will return the same result if the sequence >= 10
136136
*/
137-
def dedup(spaces: Seq[Space])(using Context): Seq[Space] = {
138-
val total = spaces.take(10)
139-
140-
if (total.size < 1 || total.size >= 10) total
137+
def dedup(spaces: Seq[Space])(using Context): Seq[Space] =
138+
if (spaces.lengthCompare(1) <= 0 || spaces.lengthCompare(10) >= 0) spaces
141139
else {
142140
val res = spaces.map(sp => (sp, spaces.filter(_ ne sp))).find {
143141
case (sp, sps) => isSubspace(sp, Or(LazyList(sps: _*)))
144142
}
145143
if (res.isEmpty) spaces
146144
else res.get._2
147145
}
148-
}
149146

150147
/** Flatten space to get rid of `Or` for pretty print */
151148
def flatten(space: Space)(using Context): Seq[Space] = space match {

0 commit comments

Comments
 (0)