Commit 908250a
perf(web): cache message date/time and sort key at parse time
Addresses review feedback on GoogleCloudPlatform#300.
- rebuildMessages sorted by re-parsing each timestamp into a Date on every
comparison; it runs per streamed message, so that is hot. Derive an
epoch-ms sortKey once at parse time and sort numerically. (Numeric key
rather than a lexicographic string compare so ordering stays correct
across the hub-store and Cloud-Logging sources even if their RFC3339
offsets ever differ.)
- renderMessages created a Date and ran Intl date/time formatting for every
message on every render; because composeText is @State, each keystroke
re-rendered the whole list and re-formatted every row. Pre-format
dateStr/timeStr once at parse time and just reference them in the loop.
deriveTimeFields centralises this parse-time derivation for both the hub
and Cloud-Logging parse paths.
No cast is added in shared/markdown.ts: marked's overload for { async: false }
already returns string (confirmed by tsc and typed lint), so `as string`
would be flagged as an unnecessary assertion here.
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>1 parent 2f4d3cf commit 908250a
2 files changed
Lines changed: 34 additions & 14 deletions
File tree
- web/src
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
64 | 64 | | |
65 | 65 | | |
66 | 66 | | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
67 | 75 | | |
68 | 76 | | |
69 | 77 | | |
70 | 78 | | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
71 | 97 | | |
72 | 98 | | |
73 | 99 | | |
| |||
637 | 663 | | |
638 | 664 | | |
639 | 665 | | |
| 666 | + | |
640 | 667 | | |
641 | 668 | | |
642 | 669 | | |
| |||
699 | 726 | | |
700 | 727 | | |
701 | 728 | | |
| 729 | + | |
702 | 730 | | |
703 | 731 | | |
704 | 732 | | |
| |||
717 | 745 | | |
718 | 746 | | |
719 | 747 | | |
720 | | - | |
721 | | - | |
722 | | - | |
| 748 | + | |
723 | 749 | | |
724 | 750 | | |
725 | 751 | | |
| |||
1074 | 1100 | | |
1075 | 1101 | | |
1076 | 1102 | | |
1077 | | - | |
1078 | | - | |
1079 | | - | |
1080 | | - | |
1081 | | - | |
1082 | | - | |
| 1103 | + | |
| 1104 | + | |
| 1105 | + | |
1083 | 1106 | | |
1084 | 1107 | | |
1085 | 1108 | | |
1086 | 1109 | | |
1087 | 1110 | | |
1088 | 1111 | | |
1089 | | - | |
1090 | | - | |
1091 | | - | |
1092 | | - | |
1093 | | - | |
1094 | 1112 | | |
1095 | 1113 | | |
1096 | 1114 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
39 | 39 | | |
40 | 40 | | |
41 | 41 | | |
| 42 | + | |
| 43 | + | |
42 | 44 | | |
43 | 45 | | |
44 | 46 | | |
| |||
0 commit comments