Opening a list moves the feed list's highlight instead of redrawing it (#490)
Profiled on production's lists at an iPhone 13's size with the CPU slowed 4x, opening four lists twice: selectFeed rebuilt every feed row (about 300 ms of the run) only to move .sel and aria-current, and dateOf made a new Intl.DateTimeFormat for every row through toLocaleDateString with options (about 155 ms). With markSelected and one shared formatter the run's CPU time fell from 2.3-2.5 s to 1.25-1.65 s; dateOf from 157 ms to 12 ms. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01RqkrVBuJRne2JAhFpaDV2U
This commit is contained in:
@@ -302,7 +302,9 @@ const ago = (t: number|null) => {
|
||||
if(d<2592000) return Math.round(d/86400)+'d ago';
|
||||
return new Date(t*1000).toLocaleDateString(undefined,{month:'short',day:'numeric',year:'numeric'});
|
||||
};
|
||||
const dateOf = (t: number|null) => t?new Date(t*1000).toLocaleDateString(undefined,{month:'short',day:'numeric',year:'numeric'}):'';
|
||||
// One formatter: toLocaleDateString with options makes a new one each call, every row of a list.
|
||||
const DATE_FMT = new Intl.DateTimeFormat(undefined,{month:'short',day:'numeric',year:'numeric'});
|
||||
const dateOf = (t: number|null) => t?DATE_FMT.format(t*1000):'';
|
||||
// A podcast episode is tens of MB, an article's image a few KB: whole MB made the small ones "0 MB".
|
||||
const mb = (n: number|null) => !n?'' : n<1048576?Math.max(1,Math.round(n/1024))+' KB'
|
||||
: n<1073741824?Math.round(n/1048576)+' MB' : (n/1073741824).toFixed(1)+' GB';
|
||||
|
||||
Reference in New Issue
Block a user