Commit a9034cb
Optimize Compressor by reusing matches vector (#375)
Moved the allocation of the `matches` vector from `calculate_block_size_near_optimal` and `compress_near_optimal_block` to the `Compressor` struct. This avoids repeated allocations for every block processed, improving Level 10 compression performance by approximately 5%.
- Added `matches: Vec<(u16, u16)>` to `Compressor` struct.
- Initialized `matches` in `Compressor::new`.
- Reused `self.matches` in `calculate_block_size_near_optimal` and `compress_near_optimal_block`.
Co-authored-by: google-labs-jules[bot] <161369871+google-labs-jules[bot]@users.noreply.github.com>1 parent 85ee61e commit a9034cb
1 file changed
Lines changed: 10 additions & 6 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
455 | 455 | | |
456 | 456 | | |
457 | 457 | | |
| 458 | + | |
458 | 459 | | |
459 | 460 | | |
460 | 461 | | |
| |||
498 | 499 | | |
499 | 500 | | |
500 | 501 | | |
| 502 | + | |
| 503 | + | |
| 504 | + | |
| 505 | + | |
| 506 | + | |
501 | 507 | | |
502 | 508 | | |
503 | 509 | | |
| |||
960 | 966 | | |
961 | 967 | | |
962 | 968 | | |
963 | | - | |
964 | 969 | | |
965 | 970 | | |
966 | 971 | | |
| |||
980 | 985 | | |
981 | 986 | | |
982 | 987 | | |
983 | | - | |
| 988 | + | |
984 | 989 | | |
985 | 990 | | |
986 | | - | |
| 991 | + | |
987 | 992 | | |
988 | 993 | | |
989 | 994 | | |
| |||
1757 | 1762 | | |
1758 | 1763 | | |
1759 | 1764 | | |
1760 | | - | |
1761 | 1765 | | |
1762 | 1766 | | |
1763 | 1767 | | |
| |||
1777 | 1781 | | |
1778 | 1782 | | |
1779 | 1783 | | |
1780 | | - | |
| 1784 | + | |
1781 | 1785 | | |
1782 | 1786 | | |
1783 | | - | |
| 1787 | + | |
1784 | 1788 | | |
1785 | 1789 | | |
1786 | 1790 | | |
| |||
0 commit comments