Repository navigation
⚡ Bolt: [성능 개선] label_section 다중 패턴 텍스트 스캔 복잡도 최적화 (O(L*N) -> O(N)) #1302
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 1 commit
4f667b5
84202e1
e1de793
9262da9
6250a5c
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -137,6 +137,8 @@ | |
| label: re.compile(re.escape(label)) for label in APPROVAL_VERIFICATION_LABELS | ||
| } | ||
|
|
||
| ANY_LABEL_PATTERN = re.compile("|".join(re.escape(label) for label in APPROVAL_VERIFICATION_LABELS)) | ||
|
|
||
| SOURCE_LIKE_CHANGED_FILE_EXTENSIONS = frozenset( | ||
| { | ||
| ".bash", | ||
|
|
@@ -979,15 +981,16 @@ def label_starts(candidate: str) -> list[int]: | |
| if not starts: | ||
| return "" | ||
|
seonghobae marked this conversation as resolved.
|
||
| start = starts[-1] + len(label) | ||
| next_starts = [ | ||
| candidate_start | ||
| for candidate in APPROVAL_VERIFICATION_LABELS | ||
| if candidate != label | ||
| for candidate_start in label_starts(candidate) | ||
| if candidate_start >= start | ||
| ] | ||
| end = min(next_starts) if next_starts else len(text) | ||
| return text[start:end] | ||
|
|
||
| match = ANY_LABEL_PATTERN.search(text, start) | ||
| while match: | ||
| idx = match.start() | ||
| matched_label = match.group(0) | ||
| if matched_label != label and idx in label_starts(matched_label): | ||
| return text[start:idx] | ||
| match = ANY_LABEL_PATTERN.search(text, match.end()) | ||
|
coderabbitai[bot] marked this conversation as resolved.
Outdated
|
||
|
|
||
| return text[start:] | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 📝 Info: label_section refactor is behaviorally equivalent The rewrite preserves the original semantics. Was this helpful? React with 👍 or 👎 to provide feedback. |
||
|
|
||
|
|
||
| def coverage_section_is_valid(section: str) -> bool: | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
📝 Info: Combined-regex correctness is fragile to future label additions
Python alternation is leftmost-then-first-alternative, not longest-match.
ANY_LABEL_PATTERN(opencode_review_normalize_output.py) stays correct only because no label is a prefix of another. Adding a label that shares a start position with an existing one could produce a shorter, wrong match depending on tuple order.Was this helpful? React with 👍 or 👎 to provide feedback.