Commit 2ff724f
committed
The `_Extra` class was over-engineered. Its only active usage was its
`strip()` method, called by `ZipFile._write_end_record()` to provide
the stripping logic for ZIP64 fields. The context-dependent nature of
extra fields also made it difficult to be reused by `_decodeExtra()`
or other methods efficiently. Additionally, its `split()` method
called `_Extra` directly rather than utilizing `cls`, which was a
suboptimal pattern that hindered extensibility.
Remove the `_Extra` class entirely and reimplement it as a module
function `_strip_extra_fields()` that processes a bytearray. This
eliminates dead and suboptimal code and improves performance by
avoiding temporary class allocations.
1 parent 65585ca commit 2ff724f
3 files changed
Lines changed: 64 additions & 69 deletions
File tree
- Lib
- test/test_zipfile
- zipfile
- Misc/NEWS.d/next/Core_and_Builtins
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
5840 | 5840 | | |
5841 | 5841 | | |
5842 | 5842 | | |
| 5843 | + | |
| 5844 | + | |
5843 | 5845 | | |
5844 | 5846 | | |
5845 | 5847 | | |
5846 | 5848 | | |
5847 | 5849 | | |
5848 | 5850 | | |
5849 | | - | |
5850 | | - | |
5851 | | - | |
5852 | | - | |
| 5851 | + | |
| 5852 | + | |
| 5853 | + | |
5853 | 5854 | | |
5854 | | - | |
5855 | | - | |
5856 | | - | |
| 5855 | + | |
| 5856 | + | |
| 5857 | + | |
5857 | 5858 | | |
5858 | 5859 | | |
5859 | 5860 | | |
5860 | 5861 | | |
5861 | 5862 | | |
5862 | 5863 | | |
5863 | 5864 | | |
5864 | | - | |
5865 | | - | |
5866 | | - | |
5867 | | - | |
| 5865 | + | |
| 5866 | + | |
| 5867 | + | |
5868 | 5868 | | |
5869 | | - | |
5870 | | - | |
5871 | | - | |
| 5869 | + | |
| 5870 | + | |
| 5871 | + | |
5872 | 5872 | | |
5873 | 5873 | | |
5874 | 5874 | | |
5875 | 5875 | | |
5876 | 5876 | | |
5877 | 5877 | | |
5878 | | - | |
5879 | | - | |
5880 | | - | |
5881 | | - | |
5882 | | - | |
5883 | | - | |
| 5878 | + | |
| 5879 | + | |
| 5880 | + | |
| 5881 | + | |
| 5882 | + | |
| 5883 | + | |
| 5884 | + | |
| 5885 | + | |
5884 | 5886 | | |
5885 | | - | |
5886 | | - | |
5887 | | - | |
| 5887 | + | |
| 5888 | + | |
| 5889 | + | |
| 5890 | + | |
| 5891 | + | |
| 5892 | + | |
| 5893 | + | |
| 5894 | + | |
| 5895 | + | |
| 5896 | + | |
| 5897 | + | |
| 5898 | + | |
| 5899 | + | |
5888 | 5900 | | |
5889 | 5901 | | |
5890 | | - | |
5891 | | - | |
5892 | | - | |
5893 | | - | |
5894 | | - | |
5895 | | - | |
| 5902 | + | |
| 5903 | + | |
| 5904 | + | |
| 5905 | + | |
5896 | 5906 | | |
5897 | 5907 | | |
5898 | 5908 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
194 | 194 | | |
195 | 195 | | |
196 | 196 | | |
197 | | - | |
198 | | - | |
199 | | - | |
200 | | - | |
201 | | - | |
202 | | - | |
203 | | - | |
204 | | - | |
205 | | - | |
206 | | - | |
207 | | - | |
208 | | - | |
209 | | - | |
210 | | - | |
211 | | - | |
212 | | - | |
213 | | - | |
214 | | - | |
215 | | - | |
216 | | - | |
217 | | - | |
218 | | - | |
219 | | - | |
220 | | - | |
221 | | - | |
222 | | - | |
223 | | - | |
224 | | - | |
225 | | - | |
226 | | - | |
227 | | - | |
228 | | - | |
229 | | - | |
230 | | - | |
231 | | - | |
232 | | - | |
233 | | - | |
234 | 197 | | |
235 | 198 | | |
236 | 199 | | |
| |||
427 | 390 | | |
428 | 391 | | |
429 | 392 | | |
| 393 | + | |
| 394 | + | |
| 395 | + | |
| 396 | + | |
| 397 | + | |
| 398 | + | |
| 399 | + | |
| 400 | + | |
| 401 | + | |
| 402 | + | |
| 403 | + | |
| 404 | + | |
| 405 | + | |
| 406 | + | |
| 407 | + | |
| 408 | + | |
| 409 | + | |
| 410 | + | |
| 411 | + | |
| 412 | + | |
| 413 | + | |
430 | 414 | | |
431 | 415 | | |
432 | 416 | | |
| |||
2665 | 2649 | | |
2666 | 2650 | | |
2667 | 2651 | | |
2668 | | - | |
2669 | | - | |
| 2652 | + | |
2670 | 2653 | | |
2671 | 2654 | | |
2672 | | - | |
| 2655 | + | |
| 2656 | + | |
2673 | 2657 | | |
2674 | 2658 | | |
2675 | 2659 | | |
| |||
Lines changed: 1 addition & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
0 commit comments