Commit 7bc8022
committed
Avoid excess copies in fletcher32
During encoding preallocate a `bytes` object for the final result and
write everything directly into it. This avoids unnecessary staging and
copying of intermediate results.
Make use of Cython typed-`memoryview`s throughout encode and decode for
efficient access of the underlying data.
Further leverage the `store_le32` and `load_le32` functions to quickly
pack and unpack little-endian 32-bit unsigned integers from buffers
when encoding and decoding.1 parent d0a7721 commit 7bc8022
1 file changed
+20
-7
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | 2 | | |
3 | 3 | | |
4 | | - | |
5 | 4 | | |
6 | 5 | | |
7 | 6 | | |
8 | 7 | | |
9 | 8 | | |
10 | 9 | | |
| 10 | + | |
| 11 | + | |
11 | 12 | | |
12 | 13 | | |
13 | 14 | | |
| |||
64 | 65 | | |
65 | 66 | | |
66 | 67 | | |
67 | | - | |
68 | | - | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
69 | 79 | | |
70 | 80 | | |
71 | 81 | | |
72 | 82 | | |
73 | | - | |
74 | | - | |
75 | | - | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
76 | 86 | | |
77 | 87 | | |
78 | 88 | | |
79 | 89 | | |
80 | 90 | | |
81 | 91 | | |
| 92 | + | |
| 93 | + | |
82 | 94 | | |
83 | | - | |
| 95 | + | |
| 96 | + | |
84 | 97 | | |
85 | 98 | | |
0 commit comments