Commit 318eea0
Encapsulate and slightly optimize string contexts
These steps are done (originally in order, but I squashed it as the end
result is still pretty small, and the churn in the code comments was a
bit annoying to keep straight).
1. Create proper struct type for string contexts on the heap
This will make it easier to change this type in the future.
2. Make `Value::StringWithContext` iterable
This make some for loops a lot more terse.
3. Encapsulate `Value::StringWithContext::Context::elems`
It turns out the iterators we just exposed are sufficient.
4. Make `StringWithContext::Context` length-prefixed instead
Rather than having a null pointer at the end, have a `size_t` at the
beginning. This is the exact same size (note that null pointer is
longer than null byte) and thus takes no more space!
Also, see the new TODO on naming. The thing we already so-named is a
builder type for string contexts, not the on-heap type. The
`fromBuilder` static method reflects what the names ought to be too.
Co-authored-by: Sergei Zimmerman <[email protected]>1 parent 6ebaba5 commit 318eea0
File tree
4 files changed
+97
-23
lines changed- src/libexpr
- include/nix/expr
- value
4 files changed
+97
-23
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
136 | 136 | | |
137 | 137 | | |
138 | 138 | | |
139 | | - | |
| 139 | + | |
140 | 140 | | |
141 | 141 | | |
142 | 142 | | |
143 | 143 | | |
144 | 144 | | |
145 | 145 | | |
146 | | - | |
147 | | - | |
| 146 | + | |
| 147 | + | |
| 148 | + | |
148 | 149 | | |
149 | | - | |
| 150 | + | |
| 151 | + | |
150 | 152 | | |
151 | 153 | | |
152 | 154 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
36 | 36 | | |
37 | 37 | | |
38 | 38 | | |
| 39 | + | |
39 | 40 | | |
40 | 41 | | |
41 | 42 | | |
| |||
821 | 822 | | |
822 | 823 | | |
823 | 824 | | |
824 | | - | |
| 825 | + | |
825 | 826 | | |
826 | | - | |
827 | | - | |
828 | | - | |
829 | | - | |
830 | | - | |
831 | | - | |
832 | | - | |
833 | | - | |
834 | | - | |
| 827 | + | |
835 | 828 | | |
| 829 | + | |
| 830 | + | |
| 831 | + | |
| 832 | + | |
| 833 | + | |
836 | 834 | | |
837 | 835 | | |
838 | 836 | | |
839 | 837 | | |
840 | | - | |
| 838 | + | |
841 | 839 | | |
842 | 840 | | |
843 | 841 | | |
844 | 842 | | |
845 | | - | |
| 843 | + | |
846 | 844 | | |
847 | 845 | | |
848 | 846 | | |
| |||
2287 | 2285 | | |
2288 | 2286 | | |
2289 | 2287 | | |
2290 | | - | |
2291 | | - | |
2292 | | - | |
| 2288 | + | |
| 2289 | + | |
| 2290 | + | |
2293 | 2291 | | |
2294 | 2292 | | |
2295 | 2293 | | |
| |||
2309 | 2307 | | |
2310 | 2308 | | |
2311 | 2309 | | |
2312 | | - | |
| 2310 | + | |
| 2311 | + | |
| 2312 | + | |
2313 | 2313 | | |
2314 | 2314 | | |
2315 | 2315 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
220 | 220 | | |
221 | 221 | | |
222 | 222 | | |
223 | | - | |
| 223 | + | |
| 224 | + | |
| 225 | + | |
| 226 | + | |
| 227 | + | |
| 228 | + | |
| 229 | + | |
| 230 | + | |
| 231 | + | |
| 232 | + | |
| 233 | + | |
| 234 | + | |
| 235 | + | |
| 236 | + | |
| 237 | + | |
| 238 | + | |
| 239 | + | |
| 240 | + | |
| 241 | + | |
| 242 | + | |
| 243 | + | |
| 244 | + | |
| 245 | + | |
| 246 | + | |
| 247 | + | |
| 248 | + | |
| 249 | + | |
| 250 | + | |
| 251 | + | |
| 252 | + | |
| 253 | + | |
| 254 | + | |
| 255 | + | |
| 256 | + | |
| 257 | + | |
| 258 | + | |
| 259 | + | |
| 260 | + | |
| 261 | + | |
| 262 | + | |
| 263 | + | |
| 264 | + | |
| 265 | + | |
| 266 | + | |
| 267 | + | |
| 268 | + | |
| 269 | + | |
| 270 | + | |
| 271 | + | |
| 272 | + | |
| 273 | + | |
| 274 | + | |
| 275 | + | |
| 276 | + | |
| 277 | + | |
| 278 | + | |
| 279 | + | |
| 280 | + | |
| 281 | + | |
| 282 | + | |
224 | 283 | | |
225 | 284 | | |
226 | 285 | | |
| |||
991 | 1050 | | |
992 | 1051 | | |
993 | 1052 | | |
994 | | - | |
| 1053 | + | |
995 | 1054 | | |
996 | 1055 | | |
997 | 1056 | | |
| |||
1117 | 1176 | | |
1118 | 1177 | | |
1119 | 1178 | | |
1120 | | - | |
| 1179 | + | |
1121 | 1180 | | |
1122 | 1181 | | |
1123 | 1182 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
24 | 24 | | |
25 | 25 | | |
26 | 26 | | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
27 | 35 | | |
28 | 36 | | |
29 | 37 | | |
| |||
77 | 85 | | |
78 | 86 | | |
79 | 87 | | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
80 | 93 | | |
81 | 94 | | |
82 | 95 | | |
0 commit comments