-
Notifications
You must be signed in to change notification settings - Fork 0
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
Duplicate code between diff()
and distance()
#9
Comments
I like this idea. Another alternative I can also think of is that we can make diff return the vector AND also the usize distance ? the only downside to this would be that now the user has to handle two variables when they might only need one. While the suggestion you provided the user can choose just to get the length or the vector. I think maybe the suggestion you made might be better. Thoughts ? Either way would require some changes to the readme instructions not a problem tho. |
Fixes #9 I had a different approach let me know what you think. For levenshtein distance I converted the matrix computations functions as a helper function. Then diff and distance call this helper function. This way we dont have any dupe code. Hamming works similar
Fixes #9 I had a different approach let me know what you think. For levenshtein distance I converted the matrix computations functions as a helper function. Then diff and distance call this helper function. This way we dont have any dupe code. Hamming works similar
Fixes #9 I had a different approach let me know what you think. For levenshtein distance I converted the matrix computations functions as a helper function. Then diff and distance call this helper function. This way we dont have any dupe code. Hamming works similar
Fixes #9 I had a different approach let me know what you think. For levenshtein distance I converted the matrix computations functions as a helper function. Then diff and distance call this helper function. This way we dont have any dupe code. Hamming works similar
Fixes #9 I had a different approach let me know what you think. For levenshtein distance I converted the matrix computations functions as a helper function. Then diff and distance call this helper function. This way we dont have any dupe code. Hamming works similar
The initial implementation seems to have caused some duplicate code between both methods defined for the implementations of the
StringDiffAlgorithm
trait.One reason the
distance()
method exists is that it's less memory-intensive. It always returns ausize
type (statically-sized), since it's guaranteed to either be 32-bit or 64-bit integer. as creating a struct requires allocating memory.diff()
allocates more memory since it's creating instances ofStringDiffOp
s, and also returns a vector, where vectors are a DST (dynamically-sized type), and therefore heap-allocated.Is there a way we can deduplicate the code? The alternative is to let the library user call the
len()
method, like:What happens though, as mentioned above, is that if they only need the distance, then it's allocating memory that'll never be used. On the other hand, it'll be a maintenance burden to manage both duplicate implementations, and it'll be easier for bugs to pop up. Thoughts?
The text was updated successfully, but these errors were encountered: