Skip to content
Open
Changes from 1 commit
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
6 changes: 5 additions & 1 deletion src/lib/tag-colors.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,9 @@ export const TAG_COLORS: TagColor[] = [
{ name: "pink", bg: "bg-pink-100 dark:bg-pink-950", text: "text-pink-700 dark:text-pink-300", border: "border-pink-200 dark:border-pink-900", activeBg: "bg-pink-600 dark:bg-pink-500", activeText: "text-white", activeBorder: "border-pink-700 dark:border-pink-400" },
];

// O(1) optimized lookup map for constant tag color data
const TAG_COLORS_MAP = new Map(TAG_COLORS.map(c => [c.name, c]));

const STORAGE_KEY = "opencitation:tag-colors";
const CHANGE_EVENT = "opencitation:tag-colors-changed";

Expand Down Expand Up @@ -56,7 +59,8 @@ function writeMap(map: Record<string, string>) {
export function resolveTagColor(tag: string, map: Record<string, string>): TagColor {
const named = map[tag];
if (named) {
const found = TAG_COLORS.find((c) => c.name === named);
// ⚡ Bolt: Replace O(N) array .find() with O(1) Map lookup
Copy link

Copilot AI Apr 30, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The inline comment includes branding/emoji ("⚡ Bolt") but doesn’t add much beyond what the code already shows. Consider replacing it with a neutral, durable explanation (or removing it) to keep comments from becoming stale/noisy over time.

Suggested change
// ⚡ Bolt: Replace O(N) array .find() with O(1) Map lookup

Copilot uses AI. Check for mistakes.
const found = TAG_COLORS_MAP.get(named);
if (found) return found;
Comment on lines 61 to 64
Copy link

Copilot AI Apr 30, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The PR description says this change was "Verified using benchmark tests and unit tests", but this PR only changes this module and doesn’t add/update any benchmark or unit test files. Either include the relevant tests/benchmarks in the PR, or update the description to reflect what was actually run and where those tests live.

Copilot uses AI. Check for mistakes.
}
return hashColor(tag);
Expand Down
Loading