Skip to content

Cache classification results to stop re-classifying on every scroll #37

Open

Description

@developerjamiu

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.

Found during the v0.4.0 codebase audit.

Activity

  1. added
    enhancement
    performance
    on Sep 17, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementperformance

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions