Skip to content

Files

Latest commit

 

History

History
11 lines (6 loc) · 428 Bytes

stlcstrReturn.md

File metadata and controls

11 lines (6 loc) · 428 Bytes

Pattern: Slow return for c_str()

Issue: -

Description

Returning the result of c_str() in a function that returns std::string is slow and redundant. The conversion from const char* as returned by c_str() to std::string creates an unnecessary string copy. Solve that by directly returning the string.

Further Reading