Optimize EhFilter comment regex memory allocation
This commit is contained in:
1 parent
0ed68b55b3
commit
bdf99d01a6
1 file changed
+4
-1
@@ -16,10 +16,13 @@
|
||||
package com.hippo.ehviewer.client
|
||||
|
||||
import android.util.Log
|
||||
import arrow.core.memoize
|
||||
import com.hippo.ehviewer.EhDB
|
||||
import com.hippo.ehviewer.client.data.GalleryInfo
|
||||
import com.hippo.ehviewer.dao.Filter
|
||||
|
||||
private val regex = { p: Filter -> Regex(p.text!!) }.memoize()
|
||||
|
||||
object EhFilter {
|
||||
val titleFilterList = mutableListOf<Filter>()
|
||||
val uploaderFilterList = mutableListOf<Filter>()
|
||||
@@ -170,6 +173,6 @@ object EhFilter {
|
||||
|
||||
@Synchronized
|
||||
fun filterComment(comment: String): Boolean {
|
||||
return commentFilterList.contains { it.enable!! && Regex(it.text!!).containsMatchIn(comment) }
|
||||
return commentFilterList.contains { it.enable!! && regex(it).containsMatchIn(comment) }
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user