Skip to content

Commit 84f7a77

Browse files
committed
Reduce SourcePosition allocations
1 parent d8555fd commit 84f7a77

File tree

2 files changed

+2
-2
lines changed

2 files changed

+2
-2
lines changed

compiler/src/dotty/tools/backend/jvm/BCodeSkelBuilder.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -535,7 +535,7 @@ trait BCodeSkelBuilder extends BCodeHelpers {
535535
}
536536
def lineNumber(tree: Tree): Unit = {
537537
if (!emitLines || !tree.span.exists) return;
538-
val nr = ctx.source.atSpan(tree.span).line + 1
538+
val nr = ctx.source.offsetToLine(tree.span.point) + 1
539539
if (nr != lastEmittedLineNr) {
540540
lastEmittedLineNr = nr
541541
lastInsn match {

compiler/src/dotty/tools/dotc/util/SourcePosition.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ extends SrcPos, interfaces.SourcePosition, Showable {
2525

2626
def point: Int = span.point
2727

28-
def line: Int = if (source.content().length != 0) source.offsetToLine(point) else -1
28+
def line: Int = if (source.length != 0) source.offsetToLine(point) else -1
2929

3030
/** Extracts the lines from the underlying source file as `Array[Char]`*/
3131
def linesSlice: Array[Char] =

0 commit comments

Comments
 (0)