Skip to content
This repository was archived by the owner on Oct 18, 2024. It is now read-only.

Commit 433201b

Browse files
committed
fix(editor/treesitter): avoid unnecessary transition from Java to JNI
1 parent 456dc2a commit 433201b

File tree

2 files changed

+2
-4
lines changed

2 files changed

+2
-4
lines changed

editor-treesitter/src/main/java/io/github/rosemoe/sora/editor/ts/TsScopedVariables.kt

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -111,9 +111,7 @@ class TsScopedVariables(tree: TSTree, text: UTF16String, val spec: TsLanguageSpe
111111
scopeStack.push(newScope)
112112
} else if (pattern in spec.localsDefinitionIndices) {
113113
val scope = scopeStack.peek()
114-
val utf16Name = text.subseqChars(startIndex, endIndex)
115-
val name = utf16Name.toString()
116-
utf16Name.close()
114+
val name = text.substringChars(startIndex, endIndex)
117115
val scopedVar = ScopedVariable(
118116
name,
119117
if (scope.forMembers) scope.startIndex else startIndex,

editor-treesitter/src/main/java/io/github/rosemoe/sora/editor/ts/predicate/builtin/Utils.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ fun getCaptureContent(
5454
) = match.captures.filter { tsQuery.getCaptureNameForId(it.index) == captureName }
5555
.map { capture ->
5656
when (text) {
57-
is UTF16String -> text.subseqBytes(capture.node.startByte, capture.node.endByte).use(UTF16String::toString)
57+
is UTF16String -> text.substringBytes(capture.node.startByte, capture.node.endByte)
5858
is Content -> text.substring(capture.node.startByte shr 1, capture.node.endByte shr 1)
5959
else -> text.substring(capture.node.startByte shr 1, capture.node.endByte shr 1)
6060
}

0 commit comments

Comments
 (0)