Skip to content

Flutter could use less sqrt(dx² + dy²) <= r and more dx² + dy² <= r² #187894

Description

@bernaferrari

Use case

sqrt is much slower than x*x and there are a few places in codebase that could be optimized. Not sure I agree with the image, but on my microbenchmarks x*x got 70% faster (not 10x but still very big improvement!)

Image

Pros: much faster.
Cons: code slightly harder to read (why is it multiplying twice or not doing sqrt?).

Activity

  1. added
    in triagePresently being triaged by the triage team
    frameworkflutter/packages/flutter repository. See also f: labels.
    f: gesturesflutter/packages/flutter/gestures repository.
    and removed
    in triagePresently being triaged by the triage team
    on Jun 12, 2026
  2. added
    P2Important issues not at the top of the work list
    perf: speedPerformance issues related to (mostly rendering) speed
    on Jun 23, 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

    P2Important issues not at the top of the work listf: gesturesflutter/packages/flutter/gestures repository.frameworkflutter/packages/flutter repository. See also f: labels.perf: speedPerformance issues related to (mostly rendering) speedteam-frameworkOwned by Framework teamtriaged-frameworkTriaged by Framework teamwaiting for PR to land (fixed)A fix is in flight

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions