Skip to content
This repository has been archived by the owner on Apr 14, 2024. It is now read-only.

Commit

Permalink
Use 50% chance to use cached value
Browse files Browse the repository at this point in the history
  • Loading branch information
dluvian committed Oct 4, 2023
1 parent 974f0f2 commit 1928db2
Showing 1 changed file with 2 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -20,14 +20,14 @@ import com.dluvian.nozzle.data.utils.AnnotatedStringUtils.pushAnnotatedString
import com.dluvian.nozzle.data.utils.AnnotatedStringUtils.pushStyledUrlAnnotation
import com.dluvian.nozzle.data.utils.HashtagUtils
import com.dluvian.nozzle.data.utils.UrlUtils
import com.dluvian.nozzle.data.utils.get80PercentTrue
import com.dluvian.nozzle.model.Pubkey
import com.dluvian.nozzle.model.nostr.Nevent
import com.dluvian.nozzle.model.nostr.NeventNostrId
import com.dluvian.nozzle.model.nostr.NoteNostrId
import com.dluvian.nozzle.model.nostr.NprofileNostrId
import com.dluvian.nozzle.model.nostr.NpubNostrId
import java.util.Collections
import kotlin.random.Random

private const val TAG = "AnnotatedContentHandler"

Expand All @@ -54,7 +54,7 @@ class AnnotatedContentHandler : IAnnotatedContentHandler {
): AnnotatedString {
if (content.isEmpty()) return AnnotatedString("")
val cached = cache[content]
if (cached != null && (mentionedNamesByPubkey.isEmpty() || get80PercentTrue())) {
if (cached != null && (mentionedNamesByPubkey.isEmpty() || Random.nextBoolean())) {
return cached
}

Expand Down

0 comments on commit 1928db2

Please sign in to comment.