Avoid redundant result iterator restarts - #4601
Open
ilkecan wants to merge 1 commit into
Open
Conversation
Up to standards ✅🟢 Issues
|
| Metric | Results |
|---|---|
| Complexity | 7 |
| Duplication | 0 |
NEW Get contextual insights on your PRs based on Codacy's metrics, along with PR and Jira context, without leaving GitHub. Enable AI reviewer
TIP This summary will be updated as you push new changes.
There was a problem hiding this comment.
Pull request overview
Optimizes ResultIterator navigation by avoiding redundant scans when already at a physical paragraph or text-line start.
Changes:
- Guards paragraph and row restarts with physical-position checks.
- Uses physical starts to detect paragraph transitions.
- Adds LTR and RTL iterator coverage.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
src/ccmain/resultiterator.cpp |
Avoids unnecessary iterator restarts and paragraph scans. |
unittest/resultiterator_test.cc |
Tests logical and physical starts across iteration levels. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Avoid redundant paragraph and text-line restarts when a
ResultIteratoris already at the required physical start position.The reading-order setup repeatedly copied iterators and restarted them even when
PageIterator::Next()had just placed them at a paragraph or text-line start. On sparse layouts with many blocks, those no-op restarts become costly repeated scans.Change
PageIterator::IsAtBeginningOf()predicatePageIterator::Next()Performance
GCC 15.2 RelWithDebInfo build, with OEM 3, PSM 11 and
OMP_THREAD_LIMIT=1:input-4267x3200.pngpage.pngThe minimal reproducer's OCR output is identical to the baseline from
main.The reproducer,
input-4267x3200.png, is generated by repeating a 16x16 texture-only image across a 4267x3200 canvas.input-4267x3200.png
background-tile-16.png
Validation