Skip to content

Extract surrogate fixup from StrBuilder.reverse() to reduce structural depth - #1764

Closed
cripto-bot wants to merge 1 commit into
apache:masterfrom
cripto-bot:graphlang-reverse-fix
Closed

Extract surrogate fixup from StrBuilder.reverse() to reduce structural depth#1764
cripto-bot wants to merge 1 commit into
apache:masterfrom
cripto-bot:graphlang-reverse-fix

Conversation

@cripto-bot

Copy link
Copy Markdown

Summary

Extracts the surrogate pair restoration logic from StrBuilder.reverse() into a dedicated restoreSurrogatePairs() method.

Motivation

The surrogate fixup loop was nested inside the main reversal method, increasing structural depth. Extracting it:

  • Reduces method complexity
  • Improves readability (surrogate logic is clearly separated)
  • Enables independent testing of the surrogate restoration

Change

  • Extracted 11 lines of surrogate fixup into private void restoreSurrogatePairs(char[], int)
  • Called from reverse() when surrogates are detected
  • No behavioral change — identical logic, same execution path

Testing

All existing StrBuilderTest tests should pass. The change is purely structural — same operations in same order.

…rogatePairs()

Reduces structural depth from 6 to 5.
Extracts surrogate pair restoration to a separate, testable method.
No behavioral change — all existing behavior preserved.

Flagged by GraphLang structural analysis (depth exceeded limit of 6).
@cripto-bot
cripto-bot force-pushed the graphlang-reverse-fix branch from 8e23041 to 1168e56 Compare July 31, 2026 15:07
@garydgregory

Copy link
Copy Markdown
Member

@cripto-bot
Closing; Change for the sake of change. If you'd like to help, please fix bugs, improve Javadocs, and so on. No PRs for internal refactorings please.

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