librdkafka icon indicating copy to clipboard operation
librdkafka copied to clipboard

rdkafkacpp: Eliminate "return by const value" pessimizations.

Open Quuxplusone opened this issue 3 years ago • 0 comments

Returning a const string means "My caller can have a copy of this string, but they aren't allowed to modify it" -- for example, they aren't allowed to use move semantics to move-out-of the returned string. Thus x = y.name(); will use copy assignment rather than move assignment. This is a needless pessimization in C++11 and later.

See also the errata marked "nxd" in https://www.aristeia.com/BookErrata/ec++3e-errata.html

Quuxplusone avatar Sep 06 '22 17:09 Quuxplusone