File tree 1 file changed +7
-11
lines changed
app/src/main/java/com/osfans/trime/ime/keyboard
1 file changed +7
-11
lines changed Original file line number Diff line number Diff line change @@ -175,17 +175,13 @@ class KeyAction(
175
175
176
176
companion object {
177
177
private val BRACED_STR = Regex (""" \{[^{}]+\}""" )
178
- private val KV_PATTERN = Regex (""" (\\w+)=(\\w+)""" )
179
178
180
- private fun decodeMapFromString (str : String ): Map <String , String > {
181
- val map = mutableMapOf<String , String >()
182
- val trimmed = str.removeSurrounding(" {" , " }" )
183
- val matches = KV_PATTERN .findAll(trimmed)
184
- for (match in matches) {
185
- val (_, k, v) = match.groupValues
186
- map[k] = v
187
- }
188
- return map
189
- }
179
+ private fun decodeMapFromString (str : String ): Map <String , String > =
180
+ str
181
+ .removeSurrounding(" {" , " }" )
182
+ .split(" , " )
183
+ .mapNotNull {
184
+ it.split(" =" ).takeIf { it.size == 2 }?.let { (key, value) -> key to value }
185
+ }.toMap()
190
186
}
191
187
}
You can’t perform that action at this time.
0 commit comments