Skip to content

Commit 3d13696

Browse files
committed
Work around 2.13 collection performance bug
1 parent e27eb9d commit 3d13696

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

compiler/src/dotty/tools/dotc/ast/Trees.scala

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -361,13 +361,16 @@ object Trees {
361361
val nameStart =
362362
if (point != span.start) point
363363
else {
364+
// Use an immutable ArraySeq to work around https://github.com/scala/bug/issues/11708
365+
val content = collection.immutable.ArraySeq.unsafeWrapArray(source.content())
366+
364367
// Point might be too far away from start to be recorded. In this case we fall back to scanning
365368
// forwards from the start offset for the name.
366369
// Note: This might be inaccurate since scanning might hit accidentally the same
367370
// name (e.g. in a comment) before finding the real definition.
368371
// To make this behavior more robust we'd have to change the trees for definitions to contain
369372
// a fully positioned Ident in place of a name.
370-
val idx = source.content().indexOfSlice(realName, point)
373+
val idx = content.indexOfSlice(realName, point)
371374
if (idx >= 0) idx
372375
else point // use `point` anyway. This is important if no source exists so scanning fails
373376
}

0 commit comments

Comments
 (0)