Skip to content

Commit 10ea712

Browse files
committed
Fixes to name comparison
Use x.length - y.length trick, Names are hash-consed.
1 parent 843ec4f commit 10ea712

File tree

1 file changed

+3
-5
lines changed

1 file changed

+3
-5
lines changed

src/dotty/tools/dotc/core/Names.scala

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -352,9 +352,9 @@ object Names {
352352
def compare(x: Name, y: Name): Int = {
353353
if (x.isTermName && y.isTypeName) 1
354354
else if (x.isTypeName && y.isTermName) -1
355-
else if (x.start == y.start && x.length == y.length) 0
355+
else if (x eq y) 0
356356
else {
357-
val until = Math.min(x.length, y.length)
357+
val until = x.length min y.length
358358
var i = 0
359359

360360
while (i < until && x(i) == y(i)) i = i + 1
@@ -363,9 +363,7 @@ object Names {
363363
if (x(i) < y(i)) -1
364364
else /*(x(i) > y(i))*/ 1
365365
} else {
366-
if (x.length < y.length) 1
367-
else if (x.length > y.length) -1
368-
else 0 // shouldn't happen, but still
366+
x.length - y.length
369367
}
370368
}
371369
}

0 commit comments

Comments
 (0)