[cmake-developers] Questions about coding conventions

Ben Boeckel ben.boeckel at kitware.com
Sun Jun 12 10:26:37 EDT 2016


On Fri, Jun 10, 2016 at 15:30:05 +0200, Daniel Pfeifer wrote:
> Passing and returning strings: We have `const char*`, `std::string`,
> and `std::string const&`. Unifying this can affect performance.
> Storing `const char*` in a `std::string` creates a (potentially
> unneded) copy (assuming it is not null).

I went through and changed all `const char*` paramters to `std::string
const&` where the pointer was given to a string within the function
(unless it was an error path or such). This allows eliding another
allocation.

> `const char*` can distinguish
> invalid from empty. Do we actually need this distinction?

It's used all over the place.

--Ben


More information about the cmake-developers mailing list