Skip to content

Commit ec6911c

Browse files
Cache compiled regex
1 parent c9f2151 commit ec6911c

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

Sources/InAnyCase/InAnyCase.swift

+3-1
Original file line numberDiff line numberDiff line change
@@ -46,10 +46,12 @@ public enum JoinStyle: WordJoinStyle {
4646
/// space case
4747
case space
4848

49+
private static let camelSplitRegex = Regex("(?<!\\p{Lu})(?=\\p{Lu})")
50+
4951
public func split(_ string: Substring) -> [Substring] {
5052
switch self {
5153
case .camel:
52-
return String(string).split(by: Regex("(?<!\\p{Lu})(?=\\p{Lu})"))
54+
return String(string).split(by: Self.camelSplitRegex)
5355
case .snake:
5456
return string.split(separator: "_")
5557
case .kebab:

0 commit comments

Comments
 (0)