From 6353366e6383ad1f6bcd98b3aab482a8eb211f38 Mon Sep 17 00:00:00 2001 From: Cuong Tran Date: Fri, 26 Apr 2024 01:32:45 +0700 Subject: [PATCH] Move Regex out of loop --- .../eu/kanade/tachiyomi/source/online/HttpSource.kt | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/source-api/src/commonMain/kotlin/eu/kanade/tachiyomi/source/online/HttpSource.kt b/source-api/src/commonMain/kotlin/eu/kanade/tachiyomi/source/online/HttpSource.kt index 2e258f640..b5abba5b7 100644 --- a/source-api/src/commonMain/kotlin/eu/kanade/tachiyomi/source/online/HttpSource.kt +++ b/source-api/src/commonMain/kotlin/eu/kanade/tachiyomi/source/online/HttpSource.kt @@ -321,12 +321,14 @@ abstract class HttpSource : CatalogueSource { protected open suspend fun fetchRelatedMangaListBySearch(manga: SManga): List { fun String.stripKeyword(): List { val regexWhitespace = Regex("\\s+") - // remove special character - return replace(Regex("[\\[(!~@#$%^&*|,?:\"<>)\\]]"), " ") + val regexSpecialCharacters = Regex("[\\[(!~@#$%^&*|,?:\"<>)\\]]") + val regexNumberOnly = Regex("^\\d+$") + + return replace(regexSpecialCharacters, " ") .split(regexWhitespace) .map { // remove number only - it.replace(Regex("^\\d+$"), "") + it.replace(regexNumberOnly, "") .lowercase(Locale.getDefault()) } // exclude single character