Skip to content

Fix O(n²) offset tracking in scholarly_to_modern#151

Draft
Copilot wants to merge 2 commits into
origin/devfrom
copilot/sub-pr-150
Draft

Fix O(n²) offset tracking in scholarly_to_modern#151
Copilot wants to merge 2 commits into
origin/devfrom
copilot/sub-pr-150

Conversation

Copilot AI commented Feb 21, 2026

Copy link
Copy Markdown
Contributor

scholarly_to_modern called len("".join(result_chars)) four times per loop iteration to track transliteration offsets, making the method O(n²) for long inputs.

Changes

  • transliterator.py: Replace all len("".join(result_chars)) offset computations with a running trans_pos integer counter, incremented by len(modern) or len(char) after each character is appended.
# Before — O(n) join on every iteration
trans_start = len("".join(result_chars))
result_chars.append(modern)
trans_end = len("".join(result_chars))

# After — O(1) counter update
trans_start = trans_pos
result_chars.append(modern)
trans_pos += len(modern)

✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.

…n²) join calls

Co-authored-by: fbkaragoz <59958216+fbkaragoz@users.noreply.github.com>
Copilot AI changed the title [WIP] Update to address feedback from PR #150 Fix O(n²) offset tracking in scholarly_to_modern Feb 21, 2026
Copilot AI requested a review from fbkaragoz February 21, 2026 05:05
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