mirror of
https://github.com/vitorpamplona/amethyst.git
synced 2025-11-10 11:57:29 +01:00
Faster calculation of uncited hashtags.
This commit is contained in:
@@ -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,
|
||||
|
||||
@@ -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>
|
||||
|
||||
@@ -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,
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user