Skip to content

⚡ Remove redundant path.move in polyline snapshot loop - #26

Merged
esenmx merged 2 commits into
masterfrom
perf/polyline-snapshot-path-move-13544136725387948932
Aug 23, 2026
Merged

esenmx merged 2 commits into
masterfrom
perf/polyline-snapshot-path-move-13544136725387948932

Conversation

@esenmx

@esenmx esenmx commented Aug 22, 2026

Copy link
Copy Markdown
Owner

💡 What:
Removed the redundant path.move(to: snapshot.point(for: coordinate)) call inside the polyline point iteration loop in FlutterPolyline.swift and updated the iteration to use coordinates.dropFirst().

🎯 Why:
path.addLine(to:) in UIBezierPath automatically updates the current point of the path. Calling move(to:) after every segment creates a new subpath for each segment, doubling snapshot.point(for:) lookups per point (from $N$ to $2N$), increasing memory overhead, and breaking line joins across polyline segments.

📊 Measured Improvement:
Direct execution of native Swift benchmarks is not supported in the Linux sandbox environment. However, algorithmically:

  • Snapshot point conversions per polyline segment decrease from $2N$ to $N$.
  • Subpath allocations decrease from $N-1$ subpaths to $1$ contiguous subpath per polyline.
  • Line joins and stroke caps now render correctly as a single joined path.

PR created automatically by Jules for task 13544136725387948932 started by @esenmx

Co-authored-by: esenmx <43244505+esenmx@users.noreply.github.com>
@google-labs-jules

Copy link
Copy Markdown
Contributor

👋 Jules, reporting for duty! I'm here to lend a hand with this pull request.

When you start a review, I'll add a 👀 emoji to each comment to let you know I've read it. I'll focus on feedback directed at me and will do my best to stay out of conversations between you and other bots or reviewers to keep the noise down.

I'll push a commit with your requested changes shortly after. Please note there might be a delay between these steps, but rest assured I'm on the job!

For more direct control, you can switch me to Reactive Mode. When this mode is on, I will only act on comments where you specifically mention me with @jules. You can find this option in the Pull Request section of your global Jules UI settings. You can always switch back!

New to Jules? Learn more at jules.google/docs.


For security, I will only act on instructions from the user who triggered this task.

Guard comment above the move(to:) so the per-segment move is not
re-added: lineJoin and dash phase only apply within one subpath,
matching MKPolylineRenderer.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@esenmx
esenmx merged commit 331ef8d into master Aug 23, 2026
7 checks passed
@esenmx
esenmx deleted the perf/polyline-snapshot-path-move-13544136725387948932 branch August 23, 2026 13:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant