Skip to content

Commit a98d521

Browse files
authored
Feedbacks from #39 (#40)
* use replaceFirstChar {} * synchronized
1 parent 67e09a3 commit a98d521

2 files changed

Lines changed: 3 additions & 22 deletions

File tree

β€Žgratatouille-wiring-runtime/src/main/kotlin/gratatouille/wiring/GratatouilleBuildService.ktβ€Ž

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ abstract class GratatouilleBuildService: BuildService<BuildServiceParameters.Non
2121
}
2222
}
2323

24+
@Synchronized
2425
override fun close() {
2526
classloaders.clear()
2627
}

β€Žgratatouille-wiring-runtime/src/main/kotlin/gratatouille/wiring/api.ktβ€Ž

Lines changed: 2 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -27,29 +27,9 @@ annotation class GPlugin(val id: String)
2727
annotation class GExtension(val pluginId: String, val extensionName: String = "", val publicType: KClass<*> = Any::class)
2828

2929
fun String.capitalizeFirstLetter(): String {
30-
val builder = StringBuilder(length)
31-
var isCapitalized = false
32-
forEach {
33-
builder.append(if (!isCapitalized && it.isLetter()) {
34-
isCapitalized = true
35-
it.toString().uppercase()
36-
} else {
37-
it.toString()
38-
})
39-
}
40-
return builder.toString()
30+
return replaceFirstChar { if (it.isLowerCase()) it.titlecaseChar() else it }
4131
}
4232

4333
fun String.decapitalizeFirstLetter(): String {
44-
val builder = StringBuilder(length)
45-
var isCapitalized = false
46-
forEach {
47-
builder.append(if (!isCapitalized && it.isLetter()) {
48-
isCapitalized = true
49-
it.toString().lowercase()
50-
} else {
51-
it.toString()
52-
})
53-
}
54-
return builder.toString()
34+
return replaceFirstChar { if (it.isUpperCase()) it.lowercaseChar() else it }
5535
}

0 commit comments

Comments
Β (0)