From f609cc70423f0aae5cd97240e5248b338d869c09 Mon Sep 17 00:00:00 2001 From: Tobias Preuss Date: Tue, 23 Jun 2020 18:19:58 +0200 Subject: [PATCH] Simplify loop and when statement. --- .../matrix/android/api/pushrules/EventMatchCondition.kt | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/matrix-sdk-android/src/main/java/im/vector/matrix/android/api/pushrules/EventMatchCondition.kt b/matrix-sdk-android/src/main/java/im/vector/matrix/android/api/pushrules/EventMatchCondition.kt index a6d7e48b9d..ca13155542 100644 --- a/matrix-sdk-android/src/main/java/im/vector/matrix/android/api/pushrules/EventMatchCondition.kt +++ b/matrix-sdk-android/src/main/java/im/vector/matrix/android/api/pushrules/EventMatchCondition.kt @@ -87,14 +87,13 @@ class EventMatchCondition( // Very simple glob to regexp converter private fun simpleGlobToRegExp(glob: String): String { var out = "" // "^" - for (i in 0 until glob.length) { - val c = glob[i] - when (c) { + for (element in glob) { + when (element) { '*' -> out += ".*" '?' -> out += '.'.toString() '.' -> out += "\\." '\\' -> out += "\\\\" - else -> out += c + else -> out += element } } out += "" // '$'.toString()