aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDmitry Petrashko <dmitry.petrashko@gmail.com>2015-07-20 11:59:18 +0200
committerDmitry Petrashko <dmitry.petrashko@gmail.com>2015-07-20 11:59:18 +0200
commit10ea7125998b0246e899706f407cc57719f37086 (patch)
treefbbd3efd79fb7e86f070fe386f866a69443fd5f7
parent843ec4f90b104281cea6fa4086b43cd98ef5f54e (diff)
downloaddotty-10ea7125998b0246e899706f407cc57719f37086.tar.gz
dotty-10ea7125998b0246e899706f407cc57719f37086.tar.bz2
dotty-10ea7125998b0246e899706f407cc57719f37086.zip
Fixes to name comparison
Use x.length - y.length trick, Names are hash-consed.
-rw-r--r--src/dotty/tools/dotc/core/Names.scala8
1 files changed, 3 insertions, 5 deletions
diff --git a/src/dotty/tools/dotc/core/Names.scala b/src/dotty/tools/dotc/core/Names.scala
index a09487280..ed41d6b6c 100644
--- a/src/dotty/tools/dotc/core/Names.scala
+++ b/src/dotty/tools/dotc/core/Names.scala
@@ -352,9 +352,9 @@ object Names {
def compare(x: Name, y: Name): Int = {
if (x.isTermName && y.isTypeName) 1
else if (x.isTypeName && y.isTermName) -1
- else if (x.start == y.start && x.length == y.length) 0
+ else if (x eq y) 0
else {
- val until = Math.min(x.length, y.length)
+ val until = x.length min y.length
var i = 0
while (i < until && x(i) == y(i)) i = i + 1
@@ -363,9 +363,7 @@ object Names {
if (x(i) < y(i)) -1
else /*(x(i) > y(i))*/ 1
} else {
- if (x.length < y.length) 1
- else if (x.length > y.length) -1
- else 0 // shouldn't happen, but still
+ x.length - y.length
}
}
}