Commit e6267ad
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 private
static method `_strip_extra_fields()` that processes a bytearray
inside `ZipFile`, positioned directly beneath its caller. This
eliminates dead and suboptimal code, achieves clean encapsulation
and code locality, and improves performance by avoiding temporary
class allocations.
1 parent 5049eb1 commit e6267ad
2 files changed
Lines changed: 60 additions & 69 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
5840 | 5840 | | |
5841 | 5841 | | |
5842 | 5842 | | |
| 5843 | + | |
| 5844 | + | |
| 5845 | + | |
| 5846 | + | |
5843 | 5847 | | |
5844 | 5848 | | |
5845 | 5849 | | |
5846 | 5850 | | |
5847 | 5851 | | |
5848 | 5852 | | |
5849 | | - | |
5850 | | - | |
5851 | | - | |
5852 | | - | |
| 5853 | + | |
| 5854 | + | |
| 5855 | + | |
5853 | 5856 | | |
5854 | | - | |
5855 | | - | |
5856 | | - | |
| 5857 | + | |
| 5858 | + | |
| 5859 | + | |
5857 | 5860 | | |
5858 | 5861 | | |
5859 | 5862 | | |
5860 | 5863 | | |
5861 | 5864 | | |
5862 | 5865 | | |
5863 | 5866 | | |
5864 | | - | |
5865 | | - | |
5866 | | - | |
5867 | | - | |
| 5867 | + | |
| 5868 | + | |
| 5869 | + | |
5868 | 5870 | | |
5869 | | - | |
5870 | | - | |
5871 | | - | |
| 5871 | + | |
| 5872 | + | |
| 5873 | + | |
5872 | 5874 | | |
5873 | 5875 | | |
5874 | 5876 | | |
5875 | 5877 | | |
5876 | 5878 | | |
5877 | 5879 | | |
5878 | | - | |
5879 | | - | |
5880 | | - | |
5881 | | - | |
5882 | | - | |
5883 | | - | |
| 5880 | + | |
| 5881 | + | |
| 5882 | + | |
| 5883 | + | |
5884 | 5884 | | |
5885 | | - | |
5886 | | - | |
5887 | | - | |
| 5885 | + | |
| 5886 | + | |
| 5887 | + | |
5888 | 5888 | | |
5889 | 5889 | | |
5890 | | - | |
5891 | | - | |
5892 | | - | |
5893 | | - | |
5894 | | - | |
5895 | | - | |
| 5890 | + | |
| 5891 | + | |
| 5892 | + | |
| 5893 | + | |
5896 | 5894 | | |
5897 | 5895 | | |
5898 | 5896 | | |
| |||
| 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 | | |
| |||
2670 | 2633 | | |
2671 | 2634 | | |
2672 | 2635 | | |
2673 | | - | |
2674 | | - | |
| 2636 | + | |
2675 | 2637 | | |
2676 | 2638 | | |
2677 | | - | |
| 2639 | + | |
| 2640 | + | |
2678 | 2641 | | |
2679 | 2642 | | |
2680 | 2643 | | |
| |||
2741 | 2704 | | |
2742 | 2705 | | |
2743 | 2706 | | |
| 2707 | + | |
| 2708 | + | |
| 2709 | + | |
| 2710 | + | |
| 2711 | + | |
| 2712 | + | |
| 2713 | + | |
| 2714 | + | |
| 2715 | + | |
| 2716 | + | |
| 2717 | + | |
| 2718 | + | |
| 2719 | + | |
| 2720 | + | |
| 2721 | + | |
| 2722 | + | |
| 2723 | + | |
| 2724 | + | |
| 2725 | + | |
| 2726 | + | |
| 2727 | + | |
| 2728 | + | |
| 2729 | + | |
| 2730 | + | |
| 2731 | + | |
| 2732 | + | |
| 2733 | + | |
| 2734 | + | |
| 2735 | + | |
| 2736 | + | |
2744 | 2737 | | |
2745 | 2738 | | |
2746 | 2739 | | |
| |||
0 commit comments