cpp-common/bt2: use bt2c::CStringView in parameters and return values throughout
From what I saw, at -O2 with gcc, passing and returning CStringViews
generates the same code as passing and returning `const char *`. Change
the `cpp-common/bt2` code to take a return C strings using CStringViews
when possible, which is more convenient than `const char *`.
Since std::string is implicitly convertible to CStringView, there is
generaly no need to have separate overloads that take std::strings.
I left the `CommonStringField::append(const std::string &)` overload,
because this one has an advantage over the `CStringView` overload: it
uses the size of the `std::string`, which is cheaper than calling
`std::strlen`.
There are some cases where leaving the `const char *` overload is
necessary. For instance, when there is also a `bool` overload. In that
case, passing a `const char *` to the function would prefer the `bool`
overload over the `CStringView` overload, which is not what we want.
Change-Id: I4c995c995da3edd2f0e9f7034053d52cb1541bb0
Signed-off-by: Simon Marchi <simon.marchi@efficios.com>
Reviewed-on: https://review.lttng.org/c/babeltrace/+/11690
Tested-by: jenkins <jenkins@lttng.org>
Reviewed-by: Philippe Proulx <eeppeliteloop@gmail.com>
This page took 0.025974 seconds and 4 git commands to generate.