Skip to content
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

Replace bool array by more compact vector #4067

Merged
merged 1 commit into from
May 6, 2023
Merged

Conversation

stweil
Copy link
Contributor

@stweil stweil commented May 5, 2023

No description provided.

@stweil
Copy link
Contributor Author

stweil commented May 5, 2023

Related issue: #4062.

@todd-richmond
Copy link

This fails with a -1 index as noted in #4062. Also, a vector is not any more compact than a stack array because a vector is just an array with more c++ isms around it

@stweil
Copy link
Contributor Author

stweil commented May 5, 2023

The old code caused an illegal memory r/w operation with index -1, while the new code raises an exception. That's a clear improvement, even if it does not fix your issue.

And std::vector<bool> "is a possibly space-efficient specialization of std::vector for the type bool", see documentation.

@todd-richmond
Copy link

it only throws an exception if you use c++ exceptions which are often disabled due to perf and general usability problems (which is why we do it). A bool vector could be a bitmask underneath, but if it is, you take a perf hit instead - probably not a great tradeoff for a small stack var - especially since the compiler can optimize bool[] any way it sees fit

@zdenop zdenop merged commit 7cc215c into tesseract-ocr:main May 6, 2023
@stweil stweil deleted the misc branch May 6, 2023 09:10
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.

3 participants