Commit fdb0aa6
committed
core: add concept of Flavour to core::str_bytes
Since core::str_bytes module cannot assume byte slices it deals with
are well-formed UTF-8 (or even WTF-8), the code must be defensive and
accept invalid sequences. This eliminates optimisations which would
be otherwise possible.
Introduce a `Flavour` trait which tags `Bytes` type with information
about the byte sequence. For example, if a `Bytes` object is created
from `&str` it’s tagged with `Utf8` flavour which gives the code
freedom to assume data is well-formed UTF-8.
This brings back all the optimisations removed in previous commit.1 parent c9dce1b commit fdb0aa6
File tree
4 files changed
+484
-168
lines changed- library/core/src
- str
4 files changed
+484
-168
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
68 | 68 | | |
69 | 69 | | |
70 | 70 | | |
| 71 | + | |
71 | 72 | | |
72 | 73 | | |
73 | 74 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
91 | 91 | | |
92 | 92 | | |
93 | 93 | | |
94 | | - | |
| 94 | + | |
95 | 95 | | |
96 | 96 | | |
97 | 97 | | |
| |||
102 | 102 | | |
103 | 103 | | |
104 | 104 | | |
105 | | - | |
106 | | - | |
107 | | - | |
| 105 | + | |
108 | 106 | | |
109 | 107 | | |
110 | 108 | | |
| |||
165 | 163 | | |
166 | 164 | | |
167 | 165 | | |
168 | | - | |
169 | | - | |
170 | | - | |
171 | | - | |
172 | | - | |
173 | | - | |
| 166 | + | |
174 | 167 | | |
175 | 168 | | |
176 | 169 | | |
| |||
180 | 173 | | |
181 | 174 | | |
182 | 175 | | |
183 | | - | |
184 | | - | |
185 | | - | |
186 | | - | |
187 | | - | |
188 | | - | |
| 176 | + | |
189 | 177 | | |
190 | 178 | | |
191 | 179 | | |
| |||
613 | 601 | | |
614 | 602 | | |
615 | 603 | | |
616 | | - | |
| 604 | + | |
617 | 605 | | |
618 | 606 | | |
619 | 607 | | |
| |||
625 | 613 | | |
626 | 614 | | |
627 | 615 | | |
628 | | - | |
629 | | - | |
630 | | - | |
| 616 | + | |
631 | 617 | | |
632 | 618 | | |
633 | 619 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
76 | 76 | | |
77 | 77 | | |
78 | 78 | | |
79 | | - | |
| 79 | + | |
80 | 80 | | |
81 | 81 | | |
82 | 82 | | |
| |||
0 commit comments