Skip to content

perf(map): cache marker icons and look pins up by id - #317

Merged
yakew7 merged 1 commit into
StudentSuite:mainfrom
propcgamer20-png:perf/map-marker-caches
Oct 27, 2026
Merged

yakew7 merged 1 commit into
StudentSuite:mainfrom
propcgamer20-png:perf/map-marker-caches

Conversation

@propcgamer20-png

Copy link
Copy Markdown
Contributor

What this changes

Closes #295. In ClusteredMarkers:

  • places.find(...) per pin is replaced by a Map built once in useMemo from places.
  • pinIcon now takes a place type and returns one cached L.DivIcon per type (exported for testing).
  • clusterIcon is cached by the per-type counts, so a cluster whose contents did not change keeps the same icon object. react-leaflet only calls marker.setIcon when the icon object changes, so unchanged pins and clusters are no longer rewritten on every moveend and zoomend.

Markup and styling of pins and clusters are unchanged.

Type of change

  • New public place(s)
  • New or updated benefit guide
  • New or updated resource link
  • Code or fix
  • Docs

Verification

  • npm run typecheck, npm run lint and npm run test:unit pass (601 tests, 2 new in map-view.test.tsx: same instance for the same type, different instance for a different type).
  • Not done: I did not measure L.Marker.prototype.setIcon call counts while panning in npm run dev, so there is no before and after count yet. That acceptance item is still open.

Checklist

  • The site hosts no copyrighted files; resource and paper changes are links only.
  • No em dashes in any copy.

@vercel

vercel Bot commented Oct 27, 2026

Copy link
Copy Markdown
Contributor

@propcgamer20-png is attempting to deploy a commit to the studentsuite Team on Vercel.

A member of the Team first needs to authorize it.

@yakew7
yakew7 merged commit a184bf7 into StudentSuite:main Oct 27, 2026
3 of 5 checks passed
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.

Map markers are rebuilt on every render and found with a linear scan

2 participants