Repository navigation
Perf/citations memoize classification - #375
Conversation
gkhngyk
left a comment
There was a problem hiding this comment.
The citations classification memoization is exactly right — per-call domainClassificationCache (by host) + articleTypeCache (by url\ntitle), looked up before calling classifyDomain / classifyArticleType, in both getCitationsOverview and getCitationGaps. Behavior-preserving (classifyCtx is constant per call, and a cached null is distinguished from a miss via === undefined). I verified typecheck + Prettier in a worktree — both pass. 🎉
Heads-up (harmless): this branch was cut from your #348 branch, so the diff also shows the formatCompactNumber files — but those are byte-identical to main now that #370 merged, so the net change vs main is only citations.ts. A squash-merge will produce a clean citations-only commit. (If you'd rather have a tidy diff, a quick rebase onto main would drop the format files — totally optional.)
Summary
Memoize expensive domain and article type classification during citations aggregation.
Changes
classifyDomain()results by host ingetCitationsOverview()classifyArticleType()results by URL + title ingetCitationsOverview()classifyDomain()results by host ingetCitationGaps()Why
Previously, repeated hosts and URLs were classified on every citation occurrence. This change memoizes classification results for the duration of each aggregation call, reducing repeated work while preserving identical behavior.
Testing