Commit 613d3d4
authored
refactor: avoid unnecessary .expect()s for empty HeaderMap (#768)
* Avoid unnecessary .expect()s for empty HeaderMap
This change removes the Result::expect() calls in the constructors for
an empty HeaderMap. These calls were provably not going to fail at
runtime but rustc's inliner wasn't smart enough to figure that out:
strings analysis of compiled binaries showed that the error message to
the expect() still showed up in generated code.
There are no behavioral differences as a result of this change.
* Move new_empty() body into `Default` impl
This gives us one fewer named method since we can use default() in place
of new_empty(). It preserves the property that `HeaderMap::new()`
constrains the generic type to `T=HeaderValue`.1 parent 181f73c commit 613d3d4
1 file changed
+15
-14
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
445 | 445 | | |
446 | 446 | | |
447 | 447 | | |
| 448 | + | |
448 | 449 | | |
449 | | - | |
| 450 | + | |
| 451 | + | |
| 452 | + | |
| 453 | + | |
| 454 | + | |
| 455 | + | |
| 456 | + | |
| 457 | + | |
| 458 | + | |
| 459 | + | |
| 460 | + | |
| 461 | + | |
| 462 | + | |
450 | 463 | | |
451 | 464 | | |
452 | 465 | | |
| |||
501 | 514 | | |
502 | 515 | | |
503 | 516 | | |
504 | | - | |
505 | | - | |
506 | | - | |
507 | | - | |
508 | | - | |
509 | | - | |
510 | | - | |
| 517 | + | |
511 | 518 | | |
512 | 519 | | |
513 | 520 | | |
| |||
2164 | 2171 | | |
2165 | 2172 | | |
2166 | 2173 | | |
2167 | | - | |
2168 | | - | |
2169 | | - | |
2170 | | - | |
2171 | | - | |
2172 | | - | |
2173 | 2174 | | |
2174 | 2175 | | |
2175 | 2176 | | |
| |||
0 commit comments