You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Cache classification results to stop re-classifying on every scroll #37
Classification is tied to initState, so every SmartText that scrolls into view in a ListView.builder fires a fresh platform channel round trip for text that was already classified moments ago.
Measured on an iPhone 17 Pro simulator, Flutter 3.47.2, 200 iterations, median:
Input
Cold call
Warm median
Pure Dart equivalent
Plain text, no links
24.6 ms
204 us
12 us
One bare URL
2.1 ms
196 us
6 us
Phone, email, URL, address, date
7.2 ms
419 us
23 us
The matching is not the cost; the channel round trip is. Even text with nothing to find costs about 200 us, which is serialisation plus a thread hop plus an event loop turn.
Fix: a small LRU cache keyed on the input string, in Dart, in front of the channel. Cache hits can resolve synchronously, which also removes the plain-then-styled flicker on every scroll.
This is the highest-leverage performance change available.
Activity