Skip to content

Commit 2a1a686

Browse files
GeorgCantorKSP Auto Pick
authored andcommitted
Update KSNameImpl.kt
Using lastIndexOf (cherry picked from commit 947bf70)
1 parent cf44710 commit 2a1a686

File tree

1 file changed

+4
-2
lines changed
  • common-util/src/main/kotlin/com/google/devtools/ksp/common/impl

1 file changed

+4
-2
lines changed

common-util/src/main/kotlin/com/google/devtools/ksp/common/impl/KSNameImpl.kt

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,12 @@ class KSNameImpl private constructor(val name: String) : KSName {
1313
}
1414

1515
override fun getQualifier(): String {
16-
return name.split(".").dropLast(1).joinToString(".")
16+
val lastIndex = name.lastIndexOf('.')
17+
return if (lastIndex != -1) name.substring(0, lastIndex) else ""
1718
}
1819

1920
override fun getShortName(): String {
20-
return name.split(".").last()
21+
val lastIndex = name.lastIndexOf('.')
22+
return if (lastIndex != -1) name.substring(lastIndex + 1) else name
2123
}
2224
}

0 commit comments

Comments
 (0)