damus

nostr ios client
git clone git://jb55.com/damus
Log | Files | Refs | README | LICENSE

commit fc534ea42d74967a0d1015999045b9e3c07f12a8
parent 54c895825086326410131e1fe80ef293e78368e2
Author: William Casarin <jb55@jb55.com>
Date:   Wed, 12 Apr 2023 19:26:05 -0700

Avoid slow string byte counting functions

Diffstat:
Mdamus/Nostr/NostrEvent.swift | 2+-
Mdamus/Nostr/RelayConnection.swift | 2+-
2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/damus/Nostr/NostrEvent.swift b/damus/Nostr/NostrEvent.swift @@ -82,7 +82,7 @@ class NostrEvent: Codable, Identifiable, CustomStringConvertible, Equatable, Has } var too_big: Bool { - return self.content.underestimatedCount > 16000 + return self.content.utf8.count > 16000 } var should_show_event: Bool { diff --git a/damus/Nostr/RelayConnection.swift b/damus/Nostr/RelayConnection.swift @@ -89,7 +89,7 @@ final class RelayConnection: WebSocketDelegate { self.isConnected = false case .text(let txt): - if txt.underestimatedCount > 2000 { + if txt.utf8.count > 2000 { DispatchQueue.global(qos: .default).async { if let ev = decode_nostr_event(txt: txt) { DispatchQueue.main.async {