Compare optimal g on a per-length-l basis. #158
Closed
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.
Before this change, most_guessable_match_sequence() could return a
different result for the same set of matches depending on their
order.
For example, consider two terminating matches for the k prefix,
match A: MA with l = LA and g = GA, and match B: MB with l = LB and g = GB,
with GA < GB and LA != LB.
Before this change, if update(MA, LA) was called before update(MB,
LB), then optimal.m[k][LB] will not contain MB. If update(MB, LB) was
called before update(MA, LA) then optimal.m[k][LB] will contain MB.
In both cases optimal.m[k][LA] contains MA.
This affects computation of bruteforce_update(k + 1), where we iterate
through optimal.m[k] and update the optimal state based on the
contents of optimal.m[k].
This change modifies update() so that it decides whether or not to
store the match in optimal.m[k][l] by only comparing g against other
optimal gs for the same length. Thus, the state of optimal.m[k][l]
is not dependent on the order of the input.