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

Performance improvement opportunities in compute_finder_penalty_score #24

Open
anforowicz opened this issue May 1, 2023 · 0 comments
Open

Comments

@anforowicz
Copy link
Contributor

Let me open an issue to capture my notes about performance improvement opportunities in compute_finder_penalty_score. Frequent boxing should be taken care of by 29296f0, but there may be additional improvement opportunities:

  • It seems that this function implements a substring search algorithm. The current implementation uses naive string searchwhich works in O(N x M) time, where N is the size of the "hay" (e.g. the width of the QR code) and M is the size of the "needle" (e.g. the size of the undesirable locator pattern - always 7 items in length). O(N + M) time should be possible using KMP or Rabin-Karp algorithm.
  • This function extracts rows/columns with the indirection of a get lambda. Maybe the indirection is optimized away by the compiler, but maybe using subslicing of Canvas::modules would be more efficient (since rows are just continuous slices). Avoiding this indirection may also be applicable to compute_adjacent_penalty_score and compute_block_penalty_score.

I don't plan to work on this, but I hope that leaving the notes above will help the next person who might want to pick it up.

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

No branches or pull requests

1 participant