From ea5f342d1093e55a138e52e6e90f01c646780b2c Mon Sep 17 00:00:00 2001 From: Nihaal Sharma <69979447+neon443@users.noreply.github.com> Date: Fri, 8 May 2026 10:49:41 +0100 Subject: [PATCH] search performance improvements --- .../UIKit/TableView/EmojiTableView.swift | 17 +++++------------ 1 file changed, 5 insertions(+), 12 deletions(-) diff --git a/StickerSlack/UIKit/TableView/EmojiTableView.swift b/StickerSlack/UIKit/TableView/EmojiTableView.swift index d9c1d27..b9a53a4 100644 --- a/StickerSlack/UIKit/TableView/EmojiTableView.swift +++ b/StickerSlack/UIKit/TableView/EmojiTableView.swift @@ -23,18 +23,15 @@ struct EmojiTableView: UIViewRepresentable { func updateUIView(_ uiView: UITableView, context: Context) { context.coordinator.hoarder = hoarder - weak let dataSourceRef: UITableViewDiffableDataSource! = uiView.dataSource as? UITableViewDiffableDataSource - var snapshotBefore = dataSourceRef.snapshot() let itemsBefore = context.coordinator.items let itemsAfter = items context.coordinator.items = items Task.detached { - guard !itemsAfter.isEmpty else { - snapshotBefore.deleteAllItems() - dataSourceRef.apply(snapshotBefore, animatingDifferences: true) + guard !itemsAfter.isEmpty || itemsBefore.count-itemsAfter.count > 10_000 else { + await context.coordinator.instantApplySnapshot() return } - dataSourceRef.apply(context.coordinator.makeSnapshot(), animatingDifferences: true) + await context.coordinator.applySnapshot(animated: true) } } @@ -69,15 +66,11 @@ struct EmojiTableView: UIViewRepresentable { } func applySnapshot(animated: Bool) async { let snapshot = makeSnapshot() - (self.tableView.dataSource as! UITableViewDiffableDataSource).apply(snapshot, animatingDifferences: animated) { - - } + await (self.tableView.dataSource as! UITableViewDiffableDataSource).apply(snapshot, animatingDifferences: animated) } func instantApplySnapshot() async { let snapshot = makeSnapshot() - (self.tableView.dataSource as! UITableViewDiffableDataSource).applySnapshotUsingReloadData(snapshot) { - - } + await (self.tableView.dataSource as! UITableViewDiffableDataSource).applySnapshotUsingReloadData(snapshot) } func cell(