We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
2 parents 36abda9 + 53cb026 commit 1f67c00Copy full SHA for 1f67c00
compiler/src/dotty/tools/dotc/core/Names.scala
@@ -546,13 +546,15 @@ object Names {
546
private[this] var size = 1
547
548
/** The hash of a name made of from characters cs[offset..offset+len-1]. */
549
- private def hashValue(cs: Array[Char], offset: Int, len: Int): Int =
550
- if (len > 0)
551
- (len * (41 * 41 * 41) +
552
- cs(offset) * (41 * 41) +
553
- cs(offset + len - 1) * 41 +
554
- cs(offset + (len >> 1)))
555
- else 0
+ private def hashValue(cs: Array[Char], offset: Int, len: Int): Int = {
+ var i = offset
+ var hash = 0
+ while (i < len + offset) {
+ hash = 31 * hash + cs(i)
+ i += 1
+ }
556
+ hash
557
558
559
/** Is (the ASCII representation of) name at given index equal to
560
* cs[offset..offset+len-1]?
0 commit comments