You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Combine all patterns into a single regex with capture groups:
constcombinedRegex=/\b(TODO|FIXME|FIX|HACK|NOTE|INFO|PERF|WARN|WARNING):/gi;letmatch;while((match=combinedRegex.exec(line)) \!==null){constpattern=match[1].toUpperCase();// look up decoration type by pattern and apply}
Problem
Currently, each line is scanned multiple times—once per pattern—using
indexOf:With 9 patterns, this means 9 passes per line.
Proposed Solution
Combine all patterns into a single regex with capture groups:
Benefits
\b) to avoid partial matches