Commit c4ce849
committed
Optimize EmailAddress storage to use single canonical representation
Refactors EmailAddress to store only one RFC 6531 (SMTPUTF8) canonical form
instead of eagerly storing all three RFC variants (5321, 5322, 6531).
Benefits:
- ~50% memory reduction (from ~208-328 bytes to ~128-168 bytes per instance)
- Single source of truth eliminates state drift
- Lazy evaluation: RFC variants computed only when accessed
- Simpler initialization logic
- Maintains full API compatibility
Implementation:
- Changed from 3 stored properties to 1 canonical + computed properties
- RFC 5321 and 5322 computed as optional (nil for internationalized addresses)
- RFC 6531 always available (canonical format)
- Added internal init(canonical:) for conversion initializers
- Simplified all conversion inits to delegate through canonical storage
All tests pass. Build verified with workspace.1 parent e991184 commit c4ce849
File tree
4 files changed
+57
-67
lines changed- Sources/EmailAddress
4 files changed
+57
-67
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
5 | 5 | | |
6 | 6 | | |
7 | 7 | | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
8 | 14 | | |
9 | | - | |
10 | | - | |
11 | | - | |
12 | | - | |
13 | | - | |
14 | | - | |
15 | | - | |
16 | | - | |
17 | | - | |
18 | | - | |
19 | | - | |
20 | | - | |
21 | | - | |
22 | | - | |
23 | | - | |
24 | | - | |
25 | | - | |
26 | | - | |
27 | | - | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
28 | 18 | | |
29 | 19 | | |
30 | 20 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
5 | 5 | | |
6 | 6 | | |
7 | 7 | | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
8 | 14 | | |
9 | | - | |
10 | | - | |
11 | | - | |
12 | | - | |
13 | | - | |
14 | | - | |
15 | | - | |
16 | | - | |
17 | | - | |
18 | | - | |
19 | | - | |
20 | | - | |
21 | | - | |
22 | | - | |
23 | | - | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
24 | 18 | | |
25 | 19 | | |
26 | 20 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
5 | 5 | | |
6 | 6 | | |
7 | 7 | | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
8 | 13 | | |
9 | | - | |
10 | | - | |
11 | | - | |
12 | | - | |
| 14 | + | |
| 15 | + | |
13 | 16 | | |
14 | 17 | | |
15 | 18 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
12 | 12 | | |
13 | 13 | | |
14 | 14 | | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
15 | 18 | | |
16 | | - | |
17 | | - | |
18 | | - | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
19 | 36 | | |
20 | 37 | | |
21 | | - | |
| 38 | + | |
22 | 39 | | |
23 | 40 | | |
24 | | - | |
| 41 | + | |
25 | 42 | | |
26 | 43 | | |
27 | 44 | | |
28 | 45 | | |
29 | 46 | | |
30 | 47 | | |
31 | | - | |
| 48 | + | |
32 | 49 | | |
33 | 50 | | |
34 | | - | |
| 51 | + | |
35 | 52 | | |
36 | | - | |
| 53 | + | |
37 | 54 | | |
38 | 55 | | |
39 | 56 | | |
40 | 57 | | |
41 | 58 | | |
42 | | - | |
43 | | - | |
44 | | - | |
45 | | - | |
46 | | - | |
47 | | - | |
48 | | - | |
49 | | - | |
50 | | - | |
51 | | - | |
52 | | - | |
53 | | - | |
54 | | - | |
55 | | - | |
56 | | - | |
57 | | - | |
58 | | - | |
59 | | - | |
60 | | - | |
| 59 | + | |
61 | 60 | | |
62 | | - | |
63 | | - | |
64 | 61 | | |
65 | 62 | | |
66 | 63 | | |
| |||
71 | 68 | | |
72 | 69 | | |
73 | 70 | | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
74 | 77 | | |
75 | 78 | | |
76 | 79 | | |
| |||
0 commit comments