Skip to content

Commit

Permalink
PinyinUtil.kt: Optimize method pinyinStr() with removing `Char.lowerc…
Browse files Browse the repository at this point in the history
…ase` and `Char.camelcase`
  • Loading branch information
1552980358 committed Sep 5, 2022
1 parent 8d5c1f8 commit b1fd3ec
Showing 1 changed file with 1 addition and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -52,11 +52,7 @@ object PinyinUtil {
else -> camelCaseEnabled = true
}

internal val Char.pinyinStr get() = when {
lowercaseEnabled -> lowercase
camelCaseEnabled -> camelcase
else -> asPinyin
}
internal val Char.pinyinStr get() = asPinyin.cases

internal val String.pinyinArrayList get() = ArrayList<String>().also { resultArrayList ->
repeat(length) { resultArrayList.add(EMPTY_STR) }
Expand Down Expand Up @@ -110,10 +106,6 @@ object PinyinUtil {
return index.toInt()
}

private val Char.lowercase get() = asPinyin.run { lowercase() }

private val Char.camelcase get() = asPinyin.camelcase

private val String.camelcase get() = when {
isEmpty() -> ""
this.length == 1 -> "${first()}"
Expand Down

0 comments on commit b1fd3ec

Please sign in to comment.