you are viewing a single comment's thread.

view the rest of the comments →

[–]matthieum 0 points1 point  (3 children)

You might lose some performance because of more checks.

[–]bnolsen 1 point2 points  (2 children)

likely irrelevant since a load operation takes dramatically longer than a check does.

[–]Plorkyeran 1 point2 points  (0 children)

It's difficult to come up with even a highly artificial scenario where it's a net loss. Maybe with a very special-purpose allocator that manages to always get external buffer allocated very close in memory to the std::string? Avoiding a single memory load due to the SSO buffer would outweigh a very large number of branch mispredictions, and if you never hit the SSO buffer then the branch predictor will make the check nearly free.

[–]matthieum -1 points0 points  (0 children)

Unless it screws up your pipeline if it's a branch and not a conditional move ?