pascalkuthe / imara-diff

Reliably performant diffing
Apache License 2.0
106 stars 9 forks source link

myers/middle_snake: correct safety doc #11

Closed jonathantanmy closed 2 months ago

jonathantanmy commented 2 months ago

Hello, one last thing that my colleague noticed. This PR is assuming that bounds_check is correct - I haven't scrutinized the algorithm enough to determine what the exact bounds are.

Again, feel free to change to meet your project's style. (This passes cargo fmt, but I don't know how long you prefer your documentation lines to be.)

Commit message follows:

In the documentation for MiddleSnakeSearch::new, the safety constraints described on the data pointer do not exactly match how the class uses it. It is stored as the kvec field, and looking at the write_xpos_at_diagonal, x_pos_at_diagonal, and pos_at_diagonal functions (a search of kvec in the source code revealing that all access to kvec go through one of these functions):

Therefore, update the documentation accordingly.

pascalkuthe commented 2 months ago

I think I wrote this safety comment very early when I started working on this and then didn't update it as the code evolved (as it's just an internal function). I did a patch release for the last fix since that could feasibly have negative effects but since this is just internal documentation and doesn't affect users I will merge this without cutting a release

jonathantanmy commented 2 months ago

Makes sense. Thanks for taking a look.