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

Commit

Permalink
fix(editor/treesitter): avoid unnecessary transition from Java to JNI
Browse files Browse the repository at this point in the history
  • Loading branch information
itsaky committed Nov 22, 2023
1 parent 456dc2a commit 433201b
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -111,9 +111,7 @@ class TsScopedVariables(tree: TSTree, text: UTF16String, val spec: TsLanguageSpe
scopeStack.push(newScope)
} else if (pattern in spec.localsDefinitionIndices) {
val scope = scopeStack.peek()
val utf16Name = text.subseqChars(startIndex, endIndex)
val name = utf16Name.toString()
utf16Name.close()
val name = text.substringChars(startIndex, endIndex)
val scopedVar = ScopedVariable(
name,
if (scope.forMembers) scope.startIndex else startIndex,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ fun getCaptureContent(
) = match.captures.filter { tsQuery.getCaptureNameForId(it.index) == captureName }
.map { capture ->
when (text) {
is UTF16String -> text.subseqBytes(capture.node.startByte, capture.node.endByte).use(UTF16String::toString)
is UTF16String -> text.substringBytes(capture.node.startByte, capture.node.endByte)
is Content -> text.substring(capture.node.startByte shr 1, capture.node.endByte shr 1)
else -> text.substring(capture.node.startByte shr 1, capture.node.endByte shr 1)
}
Expand Down

0 comments on commit 433201b

Please sign in to comment.