Faster calculation of uncited hashtags.

This commit is contained in:
Vitor Pamplona
2024-06-17 17:22:39 -04:00
parent 0fa6dce42c
commit 5d5c3ae3e3
14 changed files with 115 additions and 131 deletions

View File

@@ -89,6 +89,8 @@ open class Event(
override fun forEachTaggedEvent(onEach: (eventId: HexKey) -> Unit) = forEachTagged("e", onEach)
override fun forEachHashTag(onEach: (eventId: HexKey) -> Unit) = forEachTagged("t", onEach)
private fun forEachTagged(
tagName: String,
onEach: (eventId: HexKey) -> Unit,

View File

@@ -119,6 +119,8 @@ interface EventInterface {
fun forEachTaggedEvent(onEach: (eventId: HexKey) -> Unit)
fun forEachHashTag(onEach: (eventId: HexKey) -> Unit)
fun <R> mapTaggedEvent(map: (eventId: HexKey) -> R): List<R>
fun <R> mapTaggedAddress(map: (address: String) -> R): List<R>

View File

@@ -22,9 +22,7 @@ package com.vitorpamplona.quartz.utils
import kotlin.math.min
fun String.bytesUsedInMemory(): Int {
return (8 * ((((this.length) * 2) + 45) / 8))
}
fun String.bytesUsedInMemory(): Int = (8 * ((((this.length) * 2) + 45) / 8))
fun String.containsIgnoreCase(term: String): Boolean {
if (term.isEmpty()) return true // Empty string is contained
@@ -72,4 +70,7 @@ fun String.containsAny(terms: List<DualCase>): Boolean {
return terms.any { containsIgnoreCase(it.lowercase, it.uppercase) }
}
class DualCase(val lowercase: String, val uppercase: String)
class DualCase(
val lowercase: String,
val uppercase: String,
)