Commit d200df0
authored
[libcxx] Remove Redundant Reset in ~basic_string (llvm#164718)
8dae17b refactors basic_string for more
code reuse. This makes sense in most cases, but has performance overhead
in the case of ~basic_string. The refactoring of ~basic_string to call
__reset_internal_buffer() added a redundant (inside the destructor)
reset of the object, which the optimizer is unable to optimize away in
many cases. This patch prevents a ~1% regression we observed on an
internal workload when applying the original refactoring. This does
slightly pessimize the code readability, but I think this change is
worth it given the performance impact.
I'm hoping to add a benchmark(s) to the upstream libc++ benchmark suite
around string construction/destruction to ensure that this case does not
regress as it seems common in real world applications. I will put up a
separate PR for that when I figure out a reasonable way to write it.1 parent fa2c5fe commit d200df0
1 file changed
+6
-1
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
644 | 644 | | |
645 | 645 | | |
646 | 646 | | |
| 647 | + | |
647 | 648 | | |
648 | 649 | | |
649 | 650 | | |
| |||
918 | 919 | | |
919 | 920 | | |
920 | 921 | | |
| 922 | + | |
921 | 923 | | |
922 | 924 | | |
923 | 925 | | |
| |||
1210 | 1212 | | |
1211 | 1213 | | |
1212 | 1214 | | |
1213 | | - | |
| 1215 | + | |
| 1216 | + | |
| 1217 | + | |
| 1218 | + | |
1214 | 1219 | | |
1215 | 1220 | | |
1216 | 1221 | | |
| |||
0 commit comments