Skip to content

Conversation

@WilsonNet
Copy link
Owner

@WilsonNet WilsonNet commented Nov 27, 2025

perf(services): optimize theoryService with O(1) lookups

Replace O(n) array.indexOf() operations with O(1) Map lookups:

  • CHROMATIC_NOTES.indexOf() → CHROMATIC_NOTES_MAP.get()

  • MAJOR_KEYS.indexOf() → MAJOR_KEYS_MAP.get()

  • MINOR_KEYS.indexOf() → MINOR_KEYS_MAP.get()

  • ROMAN_NUMERALS.indexOf() → ROMAN_NUMERALS_MAP.get()

  • Constant arrays for scale semitones to avoid creating new arrays

Replace O(n) array.indexOf() operations with O(1) Map lookups:

- CHROMATIC_NOTES.indexOf() → CHROMATIC_NOTES_MAP.get()

- MAJOR_KEYS.indexOf() → MAJOR_KEYS_MAP.get()

- MINOR_KEYS.indexOf() → MINOR_KEYS_MAP.get()

- ROMAN_NUMERALS.indexOf() → ROMAN_NUMERALS_MAP.get()

- Constant arrays for scale semitones to avoid creating new arrays
@WilsonNet WilsonNet merged commit 18ac3d1 into main Nov 27, 2025
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants