Skip to content

Conversation

stweil
Copy link
Member

@stweil stweil commented May 5, 2023

No description provided.

Signed-off-by: Stefan Weil <sw@weilnetz.de>
@stweil
Copy link
Member 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
Member 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