Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .jules/bolt.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
## 2025-05-23 - Removed Dead O(N*M) Loop in Render Cycle
**Learning:** React render loops are critical paths. Calling a function that performs nested iterations (like finding a topic for a segment) inside `array.map()` for every item creates a multiplicative performance cost (O(N*M)). If the result is unused, it's pure waste.
**Action:** Always verify if the return value of a calculation inside a render loop is actually used. If not, delete it.
15 changes: 0 additions & 15 deletions components/transcript-viewer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -340,20 +340,6 @@ export function TranscriptViewer({
}
}, [handleUserScroll]);

const getSegmentTopic = (segment: TranscriptSegment): { topic: Topic; index: number } | null => {
for (let i = 0; i < topics.length; i++) {
const topic = topics[i];
const hasSegment = topic.segments.some(
(topicSeg) => segment.start >= topicSeg.start && segment.start < topicSeg.end
);
if (hasSegment) {
return { topic, index: i };
}
}
return null;
};


const getHighlightedText = (segment: TranscriptSegment, segmentIndex: number): { highlightedParts: Array<{ text: string; highlighted: boolean; isCitation?: boolean; isSearchMatch?: boolean; isCurrentSearchMatch?: boolean }> } | null => {
// Priority: Search > Citation/Topic

Expand Down Expand Up @@ -826,7 +812,6 @@ export function TranscriptViewer({
return transcript.map((segment, index) => {
const highlightedText = getHighlightedText(segment, index);
const isCurrent = index === currentSegmentIndex;
getSegmentTopic(segment);

const hasHighlight = highlightedText !== null;
const translation = translationsCache.get(index);
Expand Down