Rust icon indicating copy to clipboard operation
Rust copied to clipboard

lz77 compression algorithm implemented

Open proof185 opened this issue 1 year ago • 5 comments

proof185 avatar Apr 30 '24 00:04 proof185

Codecov Report

All modified and coverable lines are covered by tests :white_check_mark:

Project coverage is 94.81%. Comparing base (20c92d7) to head (3992a4a).

Additional details and impacted files
@@            Coverage Diff             @@
##           master     #708      +/-   ##
==========================================
+ Coverage   94.78%   94.81%   +0.02%     
==========================================
  Files         297      298       +1     
  Lines       22149    22259     +110     
==========================================
+ Hits        20994    21104     +110     
  Misses       1155     1155              

:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.

codecov-commenter avatar Apr 30 '24 00:04 codecov-commenter

Please describe the PR along with the problem's descriptions. It helps reviewers understand what the PR does. Could you explain the way you solve the problem in detail? Add docstrings to explain your code.

sozelfist avatar Apr 30 '24 01:04 sozelfist

The overall logic was good, but there are some points we need to improve in the implementation:

  • Breaking down the lz77_encode function into multiple helper functions:
    • The main lz77_encode function now delegates the task of finding the longest match to a helper function called find_longest_match.
    • find_longest_match iterates over the input string to find the longest match given a certain index.
    • Another helper function get_match_length calculates the length of the match between two substrings.

    By breaking down the functionality into smaller, focused functions, the implementation becomes easier to understand and maintain. Each function has a single responsibility, making the code more modular.

  • We should add module-level documentation and comments for functions and structs. This helps understand the purpose and usage of each component.
  • Adding a Token struct to encapsulate the information about each token generated during the compression process.
  • Implementing PartialEq for Token allows for easy comparison of tokens, which is useful for testing and general usage.
  • Using a macro for defining tests with different inputs and expected outputs is a good practice as it reduces code duplication and improves readability.

sozelfist avatar Apr 30 '24 03:04 sozelfist

This pull request has been automatically marked as abandoned because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

github-actions[bot] avatar Jun 01 '24 00:06 github-actions[bot]

Are you working on this PR @proof185. This PR is interesting, so we should work together to make it better.

sozelfist avatar Jun 01 '24 05:06 sozelfist

This pull request has been automatically marked as abandoned because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

github-actions[bot] avatar Aug 25 '24 00:08 github-actions[bot]

Please ping one of the maintainers once you commit the changes requested or make improvements on the code. If this is not the case and you need some help, feel free to ask for help in our Gitter channel. Thank you for your contributions!

github-actions[bot] avatar Sep 01 '24 00:09 github-actions[bot]