Avoid slow string byte counting functions
This commit is contained in:
@@ -82,7 +82,7 @@ class NostrEvent: Codable, Identifiable, CustomStringConvertible, Equatable, Has
|
|||||||
}
|
}
|
||||||
|
|
||||||
var too_big: Bool {
|
var too_big: Bool {
|
||||||
return self.content.underestimatedCount > 16000
|
return self.content.utf8.count > 16000
|
||||||
}
|
}
|
||||||
|
|
||||||
var should_show_event: Bool {
|
var should_show_event: Bool {
|
||||||
|
|||||||
@@ -89,7 +89,7 @@ final class RelayConnection: WebSocketDelegate {
|
|||||||
self.isConnected = false
|
self.isConnected = false
|
||||||
|
|
||||||
case .text(let txt):
|
case .text(let txt):
|
||||||
if txt.underestimatedCount > 2000 {
|
if txt.utf8.count > 2000 {
|
||||||
DispatchQueue.global(qos: .default).async {
|
DispatchQueue.global(qos: .default).async {
|
||||||
if let ev = decode_nostr_event(txt: txt) {
|
if let ev = decode_nostr_event(txt: txt) {
|
||||||
DispatchQueue.main.async {
|
DispatchQueue.main.async {
|
||||||
|
|||||||
Reference in New Issue
Block a user