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

Lazily compute longestCommonX #28

Open
make-github-pseudonymous-again opened this issue Jun 3, 2021 · 1 comment
Open

Lazily compute longestCommonX #28

make-github-pseudonymous-again opened this issue Jun 3, 2021 · 1 comment
Labels

Comments

@make-github-pseudonymous-again
Copy link
Member

make-github-pseudonymous-again commented Jun 3, 2021

Currently there are still some extensions computation that could be avoided. For instance, here

for (const k of forwardStep(centerF, D, V, eq, li, lj, ri, rj, Delta0)) {
const x = V[centerF + k];
const y = x - (k + Delta0);
V[centerF + k] = longestCommonPrefix(eq, x, lj, y, rj);
if (k - Delta < -(D - parityDelta)) continue;
if (k - Delta > D - parityDelta) continue;
if (V[centerF + k] < V[centerB + k - Delta]) continue; // TODO this scans the snake twice

The value of V[centerF + k] is not needed until the end of the forwardStep loop if the k - Delta bound checks fail.

@make-github-pseudonymous-again
Copy link
Member Author

One quick solution would be to mirror backwardExtend as forwardExtend, move the computation of V[centerF + k] until after the bound checks, and call forwardExtend once the forwardStep loop is done.

@make-github-pseudonymous-again make-github-pseudonymous-again changed the title Lazily compute and memoize longestCommonX? Lazily compute longestCommonX Jun 3, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant