[{"id":32738,"web_url":"https://patchwork.libcamera.org/comment/32738/","msgid":"<20241215205643.GQ9975@pendragon.ideasonboard.com>","date":"2024-12-15T20:56:43","subject":"Re: [RFC PATCH v1] treewide: Prefer `std::string_view` over `const\n\tstd::string&` in parameters","submitter":{"id":2,"url":"https://patchwork.libcamera.org/api/people/2/","name":"Laurent Pinchart","email":"laurent.pinchart@ideasonboard.com"},"content":"Hi Barnabás,\n\nThank you for the patch.\n\nOn Sun, Dec 15, 2024 at 08:48:06PM +0000, Barnabás Pőcze wrote:\n> A parameter of type `const std::string&` is not the right choice in\n> almost all cases. It forces the caller to construct an `std::string`\n> if they don't already have one, and accessing its data requires\n> an extra indirection. Furthermore, `std::string` is just one\n> instantiation of `std::basic_string<>`, using e.g. a different\n> allocator would immediately make it incompatible.\n\nI don't think the allocator is an issue in libcamera.\n\n> \n> In contrast to that using an `std::string_view` is better if\n> NUL termination is not needed since no `std::string` construction\n> is required, and in many cases it can be passed directly in registers.\n\nI had a go at this previously, and had very mixed feelings about the\nresult. I'll post a WIP series for discussion.\n\n> \n> Signed-off-by: Barnabás Pőcze <pobrn@protonmail.com>\n> ---\n>  include/libcamera/base/utils.h                     | 10 +++++-----\n>  include/libcamera/camera_manager.h                 |  3 ++-\n>  .../libcamera/internal/camera_sensor_properties.h  |  4 ++--\n>  include/libcamera/internal/device_enumerator.h     |  3 ++-\n>  include/libcamera/internal/formats.h               |  3 ++-\n>  include/libcamera/internal/media_device.h          |  7 ++++---\n>  include/libcamera/internal/pipeline_handler.h      |  3 ++-\n>  include/libcamera/internal/v4l2_subdevice.h        |  3 ++-\n>  include/libcamera/internal/v4l2_videodevice.h      |  3 ++-\n>  include/libcamera/pixel_format.h                   |  3 ++-\n>  src/apps/cam/capture_script.cpp                    |  2 +-\n>  src/apps/cam/capture_script.h                      |  3 ++-\n>  src/apps/cam/drm.cpp                               |  8 ++++----\n>  src/apps/cam/drm.h                                 |  9 +++++----\n>  src/ipa/libipa/camera_sensor_helper.cpp            |  2 +-\n>  src/ipa/libipa/camera_sensor_helper.h              |  3 ++-\n>  src/ipa/libipa/module.cpp                          |  2 +-\n>  src/ipa/libipa/module.h                            |  4 ++--\n>  src/libcamera/base/utils.cpp                       |  8 ++++----\n>  src/libcamera/camera_manager.cpp                   |  2 +-\n>  src/libcamera/device_enumerator.cpp                |  2 +-\n>  src/libcamera/device_enumerator_udev.cpp           |  2 +-\n>  src/libcamera/formats.cpp                          |  2 +-\n>  src/libcamera/media_device.cpp                     | 14 +++++++-------\n>  src/libcamera/pipeline_handler.cpp                 |  2 +-\n>  src/libcamera/pixel_format.cpp                     |  2 +-\n>  src/libcamera/sensor/camera_sensor_properties.cpp  |  4 ++--\n>  src/libcamera/v4l2_subdevice.cpp                   |  2 +-\n>  src/libcamera/v4l2_videodevice.cpp                 |  2 +-\n>  src/py/libcamera/py_camera_manager.h               |  2 +-\n>  src/py/libcamera/py_main.cpp                       |  2 +-\n>  31 files changed, 66 insertions(+), 55 deletions(-)\n> \n> diff --git a/include/libcamera/base/utils.h b/include/libcamera/base/utils.h\n> index 780aeda6a..3b8b3dea9 100644\n> --- a/include/libcamera/base/utils.h\n> +++ b/include/libcamera/base/utils.h\n> @@ -38,7 +38,7 @@ namespace utils {\n>  const char *basename(const char *path);\n>  \n>  char *secure_getenv(const char *name);\n> -std::string dirname(const std::string &path);\n> +std::string dirname(std::string_view path);\n>  \n>  template<typename T>\n>  std::vector<typename T::key_type> map_keys(const T &map)\n> @@ -143,7 +143,7 @@ size_t strlcpy(char *dst, const char *src, size_t size);\n>  \n>  #ifndef __DOXYGEN__\n>  template<typename Container, typename UnaryOp>\n> -std::string join(const Container &items, const std::string &sep, UnaryOp op)\n> +std::string join(const Container &items, std::string_view sep, UnaryOp op)\n>  {\n>  \tstd::ostringstream ss;\n>  \tbool first = true;\n> @@ -162,7 +162,7 @@ std::string join(const Container &items, const std::string &sep, UnaryOp op)\n>  }\n>  \n>  template<typename Container>\n> -std::string join(const Container &items, const std::string &sep)\n> +std::string join(const Container &items, std::string_view sep)\n>  {\n>  \tstd::ostringstream ss;\n>  \tbool first = true;\n> @@ -181,7 +181,7 @@ std::string join(const Container &items, const std::string &sep)\n>  }\n>  #else\n>  template<typename Container, typename UnaryOp>\n> -std::string join(const Container &items, const std::string &sep, UnaryOp op = nullptr);\n> +std::string join(const Container &items, std::string_view sep, UnaryOp op = nullptr);\n>  #endif\n>  \n>  namespace details {\n> @@ -240,7 +240,7 @@ private:\n>  \n>  details::StringSplitter split(const std::string &str, const std::string &delim);\n>  \n> -std::string toAscii(const std::string &str);\n> +std::string toAscii(std::string_view str);\n>  \n>  std::string libcameraBuildPath();\n>  std::string libcameraSourcePath();\n> diff --git a/include/libcamera/camera_manager.h b/include/libcamera/camera_manager.h\n> index b50df7825..27835500f 100644\n> --- a/include/libcamera/camera_manager.h\n> +++ b/include/libcamera/camera_manager.h\n> @@ -9,6 +9,7 @@\n>  \n>  #include <memory>\n>  #include <string>\n> +#include <string_view>\n>  #include <sys/types.h>\n>  #include <vector>\n>  \n> @@ -31,7 +32,7 @@ public:\n>  \tvoid stop();\n>  \n>  \tstd::vector<std::shared_ptr<Camera>> cameras() const;\n> -\tstd::shared_ptr<Camera> get(const std::string &id);\n> +\tstd::shared_ptr<Camera> get(std::string_view id);\n>  \n>  \tstatic const std::string &version() { return version_; }\n>  \n> diff --git a/include/libcamera/internal/camera_sensor_properties.h b/include/libcamera/internal/camera_sensor_properties.h\n> index d7d4dab62..b44093906 100644\n> --- a/include/libcamera/internal/camera_sensor_properties.h\n> +++ b/include/libcamera/internal/camera_sensor_properties.h\n> @@ -9,7 +9,7 @@\n>  \n>  #include <map>\n>  #include <stdint.h>\n> -#include <string>\n> +#include <string_view>\n>  \n>  #include <libcamera/control_ids.h>\n>  #include <libcamera/geometry.h>\n> @@ -24,7 +24,7 @@ struct CameraSensorProperties {\n>  \t\tuint8_t hblankDelay;\n>  \t};\n>  \n> -\tstatic const CameraSensorProperties *get(const std::string &sensor);\n> +\tstatic const CameraSensorProperties *get(std::string_view sensor);\n>  \n>  \tSize unitCellSize;\n>  \tstd::map<controls::draft::TestPatternModeEnum, int32_t> testPatternModes;\n> diff --git a/include/libcamera/internal/device_enumerator.h b/include/libcamera/internal/device_enumerator.h\n> index db3532a98..eecc39cfb 100644\n> --- a/include/libcamera/internal/device_enumerator.h\n> +++ b/include/libcamera/internal/device_enumerator.h\n> @@ -9,6 +9,7 @@\n>  \n>  #include <memory>\n>  #include <string>\n> +#include <string_view>\n>  #include <vector>\n>  \n>  #include <libcamera/base/signal.h>\n> @@ -48,7 +49,7 @@ public:\n>  protected:\n>  \tstd::unique_ptr<MediaDevice> createDevice(const std::string &deviceNode);\n>  \tvoid addDevice(std::unique_ptr<MediaDevice> media);\n> -\tvoid removeDevice(const std::string &deviceNode);\n> +\tvoid removeDevice(std::string_view deviceNode);\n>  \n>  private:\n>  \tstd::vector<std::shared_ptr<MediaDevice>> devices_;\n> diff --git a/include/libcamera/internal/formats.h b/include/libcamera/internal/formats.h\n> index 6a3e9c16a..bd7ac6ed1 100644\n> --- a/include/libcamera/internal/formats.h\n> +++ b/include/libcamera/internal/formats.h\n> @@ -8,6 +8,7 @@\n>  #pragma once\n>  \n>  #include <array>\n> +#include <string_view>\n>  #include <vector>\n>  \n>  #include <libcamera/geometry.h>\n> @@ -35,7 +36,7 @@ public:\n>  \n>  \tstatic const PixelFormatInfo &info(const PixelFormat &format);\n>  \tstatic const PixelFormatInfo &info(const V4L2PixelFormat &format);\n> -\tstatic const PixelFormatInfo &info(const std::string &name);\n> +\tstatic const PixelFormatInfo &info(std::string_view name);\n>  \n>  \tunsigned int stride(unsigned int width, unsigned int plane,\n>  \t\t\t    unsigned int align = 1) const;\n> diff --git a/include/libcamera/internal/media_device.h b/include/libcamera/internal/media_device.h\n> index e412d3a0b..91610a7aa 100644\n> --- a/include/libcamera/internal/media_device.h\n> +++ b/include/libcamera/internal/media_device.h\n> @@ -9,6 +9,7 @@\n>  \n>  #include <map>\n>  #include <string>\n> +#include <string_view>\n>  #include <vector>\n>  \n>  #include <linux/media.h>\n> @@ -44,10 +45,10 @@ public:\n>  \tunsigned int hwRevision() const { return hwRevision_; }\n>  \n>  \tconst std::vector<MediaEntity *> &entities() const { return entities_; }\n> -\tMediaEntity *getEntityByName(const std::string &name) const;\n> +\tMediaEntity *getEntityByName(std::string_view name) const;\n>  \n> -\tMediaLink *link(const std::string &sourceName, unsigned int sourceIdx,\n> -\t\t\tconst std::string &sinkName, unsigned int sinkIdx);\n> +\tMediaLink *link(std::string_view sourceName, unsigned int sourceIdx,\n> +\t\t\tstd::string_view sinkName, unsigned int sinkIdx);\n>  \tMediaLink *link(const MediaEntity *source, unsigned int sourceIdx,\n>  \t\t\tconst MediaEntity *sink, unsigned int sinkIdx);\n>  \tMediaLink *link(const MediaPad *source, const MediaPad *sink);\n> diff --git a/include/libcamera/internal/pipeline_handler.h b/include/libcamera/internal/pipeline_handler.h\n> index fb28a18d0..45eafce9b 100644\n> --- a/include/libcamera/internal/pipeline_handler.h\n> +++ b/include/libcamera/internal/pipeline_handler.h\n> @@ -10,6 +10,7 @@\n>  #include <memory>\n>  #include <queue>\n>  #include <string>\n> +#include <string_view>\n>  #include <sys/types.h>\n>  #include <vector>\n>  \n> @@ -112,7 +113,7 @@ public:\n>  \tconst std::string &name() const { return name_; }\n>  \n>  \tstatic std::vector<PipelineHandlerFactoryBase *> &factories();\n> -\tstatic const PipelineHandlerFactoryBase *getFactoryByName(const std::string &name);\n> +\tstatic const PipelineHandlerFactoryBase *getFactoryByName(std::string_view name);\n>  \n>  private:\n>  \tstatic void registerType(PipelineHandlerFactoryBase *factory);\n> diff --git a/include/libcamera/internal/v4l2_subdevice.h b/include/libcamera/internal/v4l2_subdevice.h\n> index 194382f84..d17365e14 100644\n> --- a/include/libcamera/internal/v4l2_subdevice.h\n> +++ b/include/libcamera/internal/v4l2_subdevice.h\n> @@ -11,6 +11,7 @@\n>  #include <optional>\n>  #include <ostream>\n>  #include <string>\n> +#include <string_view>\n>  #include <vector>\n>  \n>  #include <linux/v4l2-subdev.h>\n> @@ -161,7 +162,7 @@ public:\n>  \tconst V4L2SubdeviceCapability &caps() const { return caps_; }\n>  \n>  \tstatic std::unique_ptr<V4L2Subdevice>\n> -\tfromEntityName(const MediaDevice *media, const std::string &entity);\n> +\tfromEntityName(const MediaDevice *media, std::string_view entity);\n>  \n>  protected:\n>  \tstd::string logPrefix() const override;\n> diff --git a/include/libcamera/internal/v4l2_videodevice.h b/include/libcamera/internal/v4l2_videodevice.h\n> index f021c2a01..c256e82af 100644\n> --- a/include/libcamera/internal/v4l2_videodevice.h\n> +++ b/include/libcamera/internal/v4l2_videodevice.h\n> @@ -14,6 +14,7 @@\n>  #include <ostream>\n>  #include <stdint.h>\n>  #include <string>\n> +#include <string_view>\n>  #include <unordered_set>\n>  #include <vector>\n>  \n> @@ -228,7 +229,7 @@ public:\n>  \tSignal<> dequeueTimeout;\n>  \n>  \tstatic std::unique_ptr<V4L2VideoDevice>\n> -\tfromEntityName(const MediaDevice *media, const std::string &entity);\n> +\tfromEntityName(const MediaDevice *media, std::string_view entity);\n>  \n>  \tV4L2PixelFormat toV4L2PixelFormat(const PixelFormat &pixelFormat) const;\n>  \n> diff --git a/include/libcamera/pixel_format.h b/include/libcamera/pixel_format.h\n> index 1b4d8c7c8..874b2528b 100644\n> --- a/include/libcamera/pixel_format.h\n> +++ b/include/libcamera/pixel_format.h\n> @@ -10,6 +10,7 @@\n>  #include <ostream>\n>  #include <stdint.h>\n>  #include <string>\n> +#include <string_view>\n>  \n>  namespace libcamera {\n>  \n> @@ -38,7 +39,7 @@ public:\n>  \n>  \tstd::string toString() const;\n>  \n> -\tstatic PixelFormat fromString(const std::string &name);\n> +\tstatic PixelFormat fromString(std::string_view name);\n>  \n>  private:\n>  \tuint32_t fourcc_;\n> diff --git a/src/apps/cam/capture_script.cpp b/src/apps/cam/capture_script.cpp\n> index fc1dfa75f..d4760ea78 100644\n> --- a/src/apps/cam/capture_script.cpp\n> +++ b/src/apps/cam/capture_script.cpp\n> @@ -432,7 +432,7 @@ std::vector<std::string> CaptureScript::parseSingleArray()\n>  \t}\n>  }\n>  \n> -void CaptureScript::unpackFailure(const ControlId *id, const std::string &repr)\n> +void CaptureScript::unpackFailure(const ControlId *id, std::string_view repr)\n>  {\n>  \tstatic const std::map<unsigned int, const char *> typeNames = {\n>  \t\t{ ControlTypeNone, \"none\" },\n> diff --git a/src/apps/cam/capture_script.h b/src/apps/cam/capture_script.h\n> index 294b92036..fb40371f2 100644\n> --- a/src/apps/cam/capture_script.h\n> +++ b/src/apps/cam/capture_script.h\n> @@ -10,6 +10,7 @@\n>  #include <map>\n>  #include <memory>\n>  #include <string>\n> +#include <string_view>\n>  \n>  #include <libcamera/camera.h>\n>  #include <libcamera/controls.h>\n> @@ -67,7 +68,7 @@ private:\n>  \tstd::vector<std::string> parseSingleArray();\n>  \n>  \tvoid unpackFailure(const libcamera::ControlId *id,\n> -\t\t\t   const std::string &repr);\n> +\t\t\t   std::string_view repr);\n>  \tlibcamera::ControlValue unpackControl(const libcamera::ControlId *id);\n>  \tlibcamera::Rectangle unpackRectangle(const std::vector<std::string> &strVec);\n>  };\n> diff --git a/src/apps/cam/drm.cpp b/src/apps/cam/drm.cpp\n> index 47bbb6b05..fd9c59ec4 100644\n> --- a/src/apps/cam/drm.cpp\n> +++ b/src/apps/cam/drm.cpp\n> @@ -57,7 +57,7 @@ Object::~Object()\n>  {\n>  }\n>  \n> -const Property *Object::property(const std::string &name) const\n> +const Property *Object::property(std::string_view name) const\n>  {\n>  \tfor (const PropertyValue &pv : properties_) {\n>  \t\tconst Property *property = static_cast<const Property *>(dev_->object(pv.id()));\n> @@ -68,7 +68,7 @@ const Property *Object::property(const std::string &name) const\n>  \treturn nullptr;\n>  }\n>  \n> -const PropertyValue *Object::propertyValue(const std::string &name) const\n> +const PropertyValue *Object::propertyValue(std::string_view name) const\n>  {\n>  \tfor (const PropertyValue &pv : properties_) {\n>  \t\tconst Property *property = static_cast<const Property *>(dev_->object(pv.id()));\n> @@ -320,7 +320,7 @@ AtomicRequest::~AtomicRequest()\n>  \t\tdrmModeAtomicFree(request_);\n>  }\n>  \n> -int AtomicRequest::addProperty(const Object *object, const std::string &property,\n> +int AtomicRequest::addProperty(const Object *object, std::string_view property,\n>  \t\t\t       uint64_t value)\n>  {\n>  \tif (!valid_)\n> @@ -335,7 +335,7 @@ int AtomicRequest::addProperty(const Object *object, const std::string &property\n>  \treturn addProperty(object->id(), prop->id(), value);\n>  }\n>  \n> -int AtomicRequest::addProperty(const Object *object, const std::string &property,\n> +int AtomicRequest::addProperty(const Object *object, std::string_view property,\n>  \t\t\t       std::unique_ptr<Blob> blob)\n>  {\n>  \tif (!valid_)\n> diff --git a/src/apps/cam/drm.h b/src/apps/cam/drm.h\n> index 1ba83b6eb..aa1b06400 100644\n> --- a/src/apps/cam/drm.h\n> +++ b/src/apps/cam/drm.h\n> @@ -13,6 +13,7 @@\n>  #include <memory>\n>  #include <stdint.h>\n>  #include <string>\n> +#include <string_view>\n>  #include <vector>\n>  \n>  #include <libcamera/base/signal.h>\n> @@ -57,8 +58,8 @@ public:\n>  \tuint32_t id() const { return id_; }\n>  \tType type() const { return type_; }\n>  \n> -\tconst Property *property(const std::string &name) const;\n> -\tconst PropertyValue *propertyValue(const std::string &name) const;\n> +\tconst Property *property(std::string_view name) const;\n> +\tconst PropertyValue *propertyValue(std::string_view name) const;\n>  \tconst std::vector<PropertyValue> &properties() const { return properties_; }\n>  \n>  protected:\n> @@ -260,9 +261,9 @@ public:\n>  \tDevice *device() const { return dev_; }\n>  \tbool isValid() const { return valid_; }\n>  \n> -\tint addProperty(const Object *object, const std::string &property,\n> +\tint addProperty(const Object *object, std::string_view property,\n>  \t\t\tuint64_t value);\n> -\tint addProperty(const Object *object, const std::string &property,\n> +\tint addProperty(const Object *object, std::string_view property,\n>  \t\t\tstd::unique_ptr<Blob> blob);\n>  \tint commit(unsigned int flags = 0);\n>  \n> diff --git a/src/ipa/libipa/camera_sensor_helper.cpp b/src/ipa/libipa/camera_sensor_helper.cpp\n> index 7c66cd57d..4ed050b14 100644\n> --- a/src/ipa/libipa/camera_sensor_helper.cpp\n> +++ b/src/ipa/libipa/camera_sensor_helper.cpp\n> @@ -240,7 +240,7 @@ CameraSensorHelperFactoryBase::CameraSensorHelperFactoryBase(const std::string n\n>   * corresponding to the named factory or a null pointer if no such factory\n>   * exists\n>   */\n> -std::unique_ptr<CameraSensorHelper> CameraSensorHelperFactoryBase::create(const std::string &name)\n> +std::unique_ptr<CameraSensorHelper> CameraSensorHelperFactoryBase::create(std::string_view name)\n>  {\n>  \tconst std::vector<CameraSensorHelperFactoryBase *> &factories =\n>  \t\tCameraSensorHelperFactoryBase::factories();\n> diff --git a/src/ipa/libipa/camera_sensor_helper.h b/src/ipa/libipa/camera_sensor_helper.h\n> index a9300a64f..eedc80114 100644\n> --- a/src/ipa/libipa/camera_sensor_helper.h\n> +++ b/src/ipa/libipa/camera_sensor_helper.h\n> @@ -11,6 +11,7 @@\n>  #include <optional>\n>  #include <stdint.h>\n>  #include <string>\n> +#include <string_view>\n>  #include <variant>\n>  #include <vector>\n>  \n> @@ -56,7 +57,7 @@ public:\n>  \tCameraSensorHelperFactoryBase(const std::string name);\n>  \tvirtual ~CameraSensorHelperFactoryBase() = default;\n>  \n> -\tstatic std::unique_ptr<CameraSensorHelper> create(const std::string &name);\n> +\tstatic std::unique_ptr<CameraSensorHelper> create(std::string_view name);\n>  \n>  \tstatic std::vector<CameraSensorHelperFactoryBase *> &factories();\n>  \n> diff --git a/src/ipa/libipa/module.cpp b/src/ipa/libipa/module.cpp\n> index 64ca91419..91fb588e7 100644\n> --- a/src/ipa/libipa/module.cpp\n> +++ b/src/ipa/libipa/module.cpp\n> @@ -107,7 +107,7 @@ namespace ipa {\n>   */\n>  \n>  /**\n> - * \\fn Module::createAlgorithm(const std::string &name)\n> + * \\fn Module::createAlgorithm(std::string_view name)\n>   * \\brief Create an instance of an Algorithm by name\n>   * \\param[in] name The algorithm name\n>   *\n> diff --git a/src/ipa/libipa/module.h b/src/ipa/libipa/module.h\n> index 0fb51916f..62c700a64 100644\n> --- a/src/ipa/libipa/module.h\n> +++ b/src/ipa/libipa/module.h\n> @@ -9,7 +9,7 @@\n>  \n>  #include <list>\n>  #include <memory>\n> -#include <string>\n> +#include <string_view>\n>  #include <vector>\n>  \n>  #include <libcamera/base/log.h>\n> @@ -95,7 +95,7 @@ private:\n>  \t\treturn 0;\n>  \t}\n>  \n> -\tstatic std::unique_ptr<Algorithm<Module>> createAlgorithm(const std::string &name)\n> +\tstatic std::unique_ptr<Algorithm<Module>> createAlgorithm(std::string_view name)\n>  \t{\n>  \t\tfor (const AlgorithmFactoryBase<Module> *factory : factories()) {\n>  \t\t\tif (factory->name() == name)\n> diff --git a/src/libcamera/base/utils.cpp b/src/libcamera/base/utils.cpp\n> index bcfc1941a..de6e2afd6 100644\n> --- a/src/libcamera/base/utils.cpp\n> +++ b/src/libcamera/base/utils.cpp\n> @@ -80,7 +80,7 @@ char *secure_getenv(const char *name)\n>   *\n>   * \\return A string of the directory component of the path\n>   */\n> -std::string dirname(const std::string &path)\n> +std::string dirname(std::string_view path)\n>  {\n>  \tif (path.empty())\n>  \t\treturn \".\";\n> @@ -116,7 +116,7 @@ std::string dirname(const std::string &path)\n>  \t\tpos--;\n>  \t}\n>  \n> -\treturn path.substr(0, pos + 1);\n> +\treturn std::string(path.substr(0, pos + 1));\n>  }\n>  \n>  /**\n> @@ -278,7 +278,7 @@ std::string details::StringSplitter::iterator::operator*() const\n>  \n>  /**\n>   * \\fn template<typename Container, typename UnaryOp> \\\n> - * std::string utils::join(const Container &items, const std::string &sep, UnaryOp op)\n> + * std::string utils::join(const Container &items, std::string_view sep, UnaryOp op)\n>   * \\brief Join elements of a container in a string with a separator\n>   * \\param[in] items The container\n>   * \\param[in] sep The separator to add between elements\n> @@ -319,7 +319,7 @@ details::StringSplitter split(const std::string &str, const std::string &delim)\n>   *\n>   * \\return A string equal to \\a str stripped out of all non-ASCII characters\n>   */\n> -std::string toAscii(const std::string &str)\n> +std::string toAscii(std::string_view str)\n>  {\n>  \tstd::string ret;\n>  \tfor (const char &c : str)\n> diff --git a/src/libcamera/camera_manager.cpp b/src/libcamera/camera_manager.cpp\n> index 87e6717ec..179fa37ea 100644\n> --- a/src/libcamera/camera_manager.cpp\n> +++ b/src/libcamera/camera_manager.cpp\n> @@ -382,7 +382,7 @@ std::vector<std::shared_ptr<Camera>> CameraManager::cameras() const\n>   *\n>   * \\return Shared pointer to Camera object or nullptr if camera not found\n>   */\n> -std::shared_ptr<Camera> CameraManager::get(const std::string &id)\n> +std::shared_ptr<Camera> CameraManager::get(std::string_view id)\n>  {\n>  \tPrivate *const d = _d();\n>  \n> diff --git a/src/libcamera/device_enumerator.cpp b/src/libcamera/device_enumerator.cpp\n> index ae17862f6..8744a90f3 100644\n> --- a/src/libcamera/device_enumerator.cpp\n> +++ b/src/libcamera/device_enumerator.cpp\n> @@ -272,7 +272,7 @@ void DeviceEnumerator::addDevice(std::unique_ptr<MediaDevice> media)\n>   * enumerator with addDevice(). The media device's MediaDevice::disconnected\n>   * signal is emitted.\n>   */\n> -void DeviceEnumerator::removeDevice(const std::string &deviceNode)\n> +void DeviceEnumerator::removeDevice(std::string_view deviceNode)\n>  {\n>  \tstd::shared_ptr<MediaDevice> media;\n>  \n> diff --git a/src/libcamera/device_enumerator_udev.cpp b/src/libcamera/device_enumerator_udev.cpp\n> index 4e20a3cc0..c330f30bc 100644\n> --- a/src/libcamera/device_enumerator_udev.cpp\n> +++ b/src/libcamera/device_enumerator_udev.cpp\n> @@ -351,7 +351,7 @@ void DeviceEnumeratorUdev::udevNotify()\n>  \t} else if (action == \"remove\") {\n>  \t\tconst char *subsystem = udev_device_get_subsystem(dev);\n>  \t\tif (subsystem && !strcmp(subsystem, \"media\"))\n> -\t\t\tremoveDevice(std::string(deviceNode));\n> +\t\t\tremoveDevice(deviceNode);\n>  \t}\n>  \n>  \tudev_device_unref(dev);\n> diff --git a/src/libcamera/formats.cpp b/src/libcamera/formats.cpp\n> index bfcdfc089..112dfe66b 100644\n> --- a/src/libcamera/formats.cpp\n> +++ b/src/libcamera/formats.cpp\n> @@ -1037,7 +1037,7 @@ const PixelFormatInfo &PixelFormatInfo::info(const V4L2PixelFormat &format)\n>   * \\return The PixelFormatInfo describing the PixelFormat matching the\n>   * \\a name if known, or an invalid PixelFormatInfo otherwise\n>   */\n> -const PixelFormatInfo &PixelFormatInfo::info(const std::string &name)\n> +const PixelFormatInfo &PixelFormatInfo::info(std::string_view name)\n>  {\n>  \tfor (const auto &info : pixelFormatInfo) {\n>  \t\tif (info.second.name == name)\n> diff --git a/src/libcamera/media_device.cpp b/src/libcamera/media_device.cpp\n> index d71dad74d..131b34446 100644\n> --- a/src/libcamera/media_device.cpp\n> +++ b/src/libcamera/media_device.cpp\n> @@ -331,7 +331,7 @@ done:\n>   * \\param[in] name The entity name\n>   * \\return The entity with \\a name, or nullptr if no such entity is found\n>   */\n> -MediaEntity *MediaDevice::getEntityByName(const std::string &name) const\n> +MediaEntity *MediaDevice::getEntityByName(std::string_view name) const\n>  {\n>  \tfor (MediaEntity *e : entities_)\n>  \t\tif (e->name() == name)\n> @@ -359,8 +359,8 @@ MediaEntity *MediaDevice::getEntityByName(const std::string &name) const\n>   * \\return The link that connects the two pads, or nullptr if no such a link\n>   * exists\n>   */\n> -MediaLink *MediaDevice::link(const std::string &sourceName, unsigned int sourceIdx,\n> -\t\t\t     const std::string &sinkName, unsigned int sinkIdx)\n> +MediaLink *MediaDevice::link(std::string_view sourceName, unsigned int sourceIdx,\n> +\t\t\t     std::string_view sinkName, unsigned int sinkIdx)\n>  {\n>  \tconst MediaEntity *source = getEntityByName(sourceName);\n>  \tconst MediaEntity *sink = getEntityByName(sinkName);\n> @@ -382,8 +382,8 @@ MediaLink *MediaDevice::link(const std::string &sourceName, unsigned int sourceI\n>   * entity \\a source, to the pad at index \\a sinkIdx of the sink entity \\a\n>   * sink, if any.\n>   *\n> - * \\sa link(const std::string &sourceName, unsigned int sourceIdx,\n> - *          const std::string &sinkName, unsigned int sinkIdx)\n> + * \\sa link(std::string_view sourceName, unsigned int sourceIdx,\n> + *          std::string_view sinkName, unsigned int sinkIdx)\n>   * \\sa link(const MediaPad *source, const MediaPad *sink)\n>   *\n>   * \\return The link that connects the two pads, or nullptr if no such a link\n> @@ -406,8 +406,8 @@ MediaLink *MediaDevice::link(const MediaEntity *source, unsigned int sourceIdx,\n>   * \\param[in] source The source pad\n>   * \\param[in] sink The sink pad\n>   *\n> - * \\sa link(const std::string &sourceName, unsigned int sourceIdx,\n> - *          const std::string &sinkName, unsigned int sinkIdx)\n> + * \\sa link(std::string_view sourceName, unsigned int sourceIdx,\n> + *          std::string_view sinkName, unsigned int sinkIdx)\n>   * \\sa link(const MediaEntity *source, unsigned int sourceIdx,\n>   *          const MediaEntity *sink, unsigned int sinkIdx)\n>   *\n> diff --git a/src/libcamera/pipeline_handler.cpp b/src/libcamera/pipeline_handler.cpp\n> index caa5c20e7..6b395c666 100644\n> --- a/src/libcamera/pipeline_handler.cpp\n> +++ b/src/libcamera/pipeline_handler.cpp\n> @@ -852,7 +852,7 @@ std::vector<PipelineHandlerFactoryBase *> &PipelineHandlerFactoryBase::factories\n>   * \\param[in] name The pipeline handler name\n>   * \\return The factory of the pipeline with name \\a name, or nullptr if not found\n>   */\n> -const PipelineHandlerFactoryBase *PipelineHandlerFactoryBase::getFactoryByName(const std::string &name)\n> +const PipelineHandlerFactoryBase *PipelineHandlerFactoryBase::getFactoryByName(std::string_view name)\n>  {\n>  \tconst std::vector<PipelineHandlerFactoryBase *> &factories =\n>  \t\tPipelineHandlerFactoryBase::factories();\n> diff --git a/src/libcamera/pixel_format.cpp b/src/libcamera/pixel_format.cpp\n> index 314179a81..22f1520fd 100644\n> --- a/src/libcamera/pixel_format.cpp\n> +++ b/src/libcamera/pixel_format.cpp\n> @@ -135,7 +135,7 @@ std::string PixelFormat::toString() const\n>   * \\return The PixelFormat represented by the \\a name if known, or an\n>   * invalid pixel format otherwise.\n>   */\n> -PixelFormat PixelFormat::fromString(const std::string &name)\n> +PixelFormat PixelFormat::fromString(std::string_view name)\n>  {\n>  \treturn PixelFormatInfo::info(name).format;\n>  }\n> diff --git a/src/libcamera/sensor/camera_sensor_properties.cpp b/src/libcamera/sensor/camera_sensor_properties.cpp\n> index 2b06c5a1a..4283cacfa 100644\n> --- a/src/libcamera/sensor/camera_sensor_properties.cpp\n> +++ b/src/libcamera/sensor/camera_sensor_properties.cpp\n> @@ -78,9 +78,9 @@ LOG_DEFINE_CATEGORY(CameraSensorProperties)\n>   * \\return A pointer to the CameraSensorProperties instance associated with a sensor\n>   * or nullptr if the sensor is not supported\n>   */\n> -const CameraSensorProperties *CameraSensorProperties::get(const std::string &sensor)\n> +const CameraSensorProperties *CameraSensorProperties::get(std::string_view sensor)\n>  {\n> -\tstatic const std::map<std::string, const CameraSensorProperties> sensorProps = {\n> +\tstatic const std::map<std::string_view, const CameraSensorProperties> sensorProps = {\n>  \t\t{ \"ar0144\", {\n>  \t\t\t.unitCellSize = { 3000, 3000 },\n>  \t\t\t.testPatternModes = {\n> diff --git a/src/libcamera/v4l2_subdevice.cpp b/src/libcamera/v4l2_subdevice.cpp\n> index 3a0d075f9..7e85b33be 100644\n> --- a/src/libcamera/v4l2_subdevice.cpp\n> +++ b/src/libcamera/v4l2_subdevice.cpp\n> @@ -1688,7 +1688,7 @@ const std::string &V4L2Subdevice::model()\n>   */\n>  std::unique_ptr<V4L2Subdevice>\n>  V4L2Subdevice::fromEntityName(const MediaDevice *media,\n> -\t\t\t      const std::string &entity)\n> +\t\t\t      std::string_view entity)\n>  {\n>  \tMediaEntity *mediaEntity = media->getEntityByName(entity);\n>  \tif (!mediaEntity)\n> diff --git a/src/libcamera/v4l2_videodevice.cpp b/src/libcamera/v4l2_videodevice.cpp\n> index a5cf67845..834a1bd0d 100644\n> --- a/src/libcamera/v4l2_videodevice.cpp\n> +++ b/src/libcamera/v4l2_videodevice.cpp\n> @@ -2077,7 +2077,7 @@ void V4L2VideoDevice::watchdogExpired()\n>   */\n>  std::unique_ptr<V4L2VideoDevice>\n>  V4L2VideoDevice::fromEntityName(const MediaDevice *media,\n> -\t\t\t\tconst std::string &entity)\n> +\t\t\t\tstd::string_view entity)\n>  {\n>  \tMediaEntity *mediaEntity = media->getEntityByName(entity);\n>  \tif (!mediaEntity)\n> diff --git a/src/py/libcamera/py_camera_manager.h b/src/py/libcamera/py_camera_manager.h\n> index 3574db236..af69b915e 100644\n> --- a/src/py/libcamera/py_camera_manager.h\n> +++ b/src/py/libcamera/py_camera_manager.h\n> @@ -20,7 +20,7 @@ public:\n>  \t~PyCameraManager();\n>  \n>  \tpybind11::list cameras();\n> -\tstd::shared_ptr<Camera> get(const std::string &name) { return cameraManager_->get(name); }\n> +\tstd::shared_ptr<Camera> get(std::string_view name) { return cameraManager_->get(name); }\n>  \n>  \tstatic const std::string &version() { return CameraManager::version(); }\n>  \n> diff --git a/src/py/libcamera/py_main.cpp b/src/py/libcamera/py_main.cpp\n> index 441a70ab4..820768c24 100644\n> --- a/src/py/libcamera/py_main.cpp\n> +++ b/src/py/libcamera/py_main.cpp\n> @@ -510,7 +510,7 @@ PYBIND11_MODULE(_libcamera, m)\n>  \tpyPixelFormat\n>  \t\t.def(py::init<>())\n>  \t\t.def(py::init<uint32_t, uint64_t>())\n> -\t\t.def(py::init<>([](const std::string &str) {\n> +\t\t.def(py::init<>([](std::string_view str) {\n>  \t\t\treturn PixelFormat::fromString(str);\n>  \t\t}))\n>  \t\t.def_property_readonly(\"fourcc\", &PixelFormat::fourcc)","headers":{"Return-Path":"<libcamera-devel-bounces@lists.libcamera.org>","X-Original-To":"parsemail@patchwork.libcamera.org","Delivered-To":"parsemail@patchwork.libcamera.org","Received":["from lancelot.ideasonboard.com (lancelot.ideasonboard.com\n\t[92.243.16.209])\n\tby patchwork.libcamera.org (Postfix) with ESMTPS id 23523C32F6\n\tfor <parsemail@patchwork.libcamera.org>;\n\tSun, 15 Dec 2024 20:57:03 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 2EB3767F1F;\n\tSun, 15 Dec 2024 21:57:02 +0100 (CET)","from perceval.ideasonboard.com (perceval.ideasonboard.com\n\t[213.167.242.64])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id C660267F1C\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tSun, 15 Dec 2024 21:57:00 +0100 (CET)","from pendragon.ideasonboard.com (81-175-209-231.bb.dnainternet.fi\n\t[81.175.209.231])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id 5E4AB7E9;\n\tSun, 15 Dec 2024 21:56:24 +0100 (CET)"],"Authentication-Results":"lancelot.ideasonboard.com; dkim=pass (1024-bit key;\n\tunprotected) header.d=ideasonboard.com header.i=@ideasonboard.com\n\theader.b=\"JK51kXb7\"; dkim-atps=neutral","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1734296184;\n\tbh=qQD3Sm9gTxk+9vRFMuHK0jR3cKS3e+dyZ2RBDx+gJ70=;\n\th=Date:From:To:Cc:Subject:References:In-Reply-To:From;\n\tb=JK51kXb7kx8jItFVHgBS5j00qhExFFhzGIxTgFkguK0804hGwmcfwo7cPOK9C5tc6\n\t0Ju3s5xJFhZbJFV2B98XhP+hx7oSEwReb8iN3irOVl+nJ0uAGx2FslVyKsK5Lkqx2s\n\tAiOQpJ+XFbgXcny/EvaWHAi+ccN9CTzhWHQZd1Co=","Date":"Sun, 15 Dec 2024 22:56:43 +0200","From":"Laurent Pinchart <laurent.pinchart@ideasonboard.com>","To":"=?utf-8?q?Barnab=C3=A1s_P=C5=91cze?= <pobrn@protonmail.com>","Cc":"libcamera-devel@lists.libcamera.org","Subject":"Re: [RFC PATCH v1] treewide: Prefer `std::string_view` over `const\n\tstd::string&` in parameters","Message-ID":"<20241215205643.GQ9975@pendragon.ideasonboard.com>","References":"<20241215204802.850593-1-pobrn@protonmail.com>","MIME-Version":"1.0","Content-Type":"text/plain; charset=utf-8","Content-Disposition":"inline","Content-Transfer-Encoding":"8bit","In-Reply-To":"<20241215204802.850593-1-pobrn@protonmail.com>","X-BeenThere":"libcamera-devel@lists.libcamera.org","X-Mailman-Version":"2.1.29","Precedence":"list","List-Id":"<libcamera-devel.lists.libcamera.org>","List-Unsubscribe":"<https://lists.libcamera.org/options/libcamera-devel>,\n\t<mailto:libcamera-devel-request@lists.libcamera.org?subject=unsubscribe>","List-Archive":"<https://lists.libcamera.org/pipermail/libcamera-devel/>","List-Post":"<mailto:libcamera-devel@lists.libcamera.org>","List-Help":"<mailto:libcamera-devel-request@lists.libcamera.org?subject=help>","List-Subscribe":"<https://lists.libcamera.org/listinfo/libcamera-devel>,\n\t<mailto:libcamera-devel-request@lists.libcamera.org?subject=subscribe>","Errors-To":"libcamera-devel-bounces@lists.libcamera.org","Sender":"\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>"}},{"id":32743,"web_url":"https://patchwork.libcamera.org/comment/32743/","msgid":"<ZhYd-vdQuuQt3zHES9ZrjP_B7Hg-a4_I1GF91qrXD6bvrqDdknz8eZD5dyBt5fIlLd-QrybBSaiGaG-ISVwnuxXkX4oilIm2gCPZ19mYbBY=@protonmail.com>","date":"2024-12-15T22:46:35","subject":"Re: [RFC PATCH v1] treewide: Prefer `std::string_view` over `const\n\tstd::string&` in parameters","submitter":{"id":133,"url":"https://patchwork.libcamera.org/api/people/133/","name":"Pőcze Barnabás","email":"pobrn@protonmail.com"},"content":"Hi\n\n\n2024. december 15., vasárnap 21:56 keltezéssel, Laurent Pinchart <laurent.pinchart@ideasonboard.com> írta:\n\n> Hi Barnabás,\n> \n> Thank you for the patch.\n> \n> On Sun, Dec 15, 2024 at 08:48:06PM +0000, Barnabás Pőcze wrote:\n> > A parameter of type `const std::string&` is not the right choice in\n> > almost all cases. It forces the caller to construct an `std::string`\n> > if they don't already have one, and accessing its data requires\n> > an extra indirection. Furthermore, `std::string` is just one\n> > instantiation of `std::basic_string<>`, using e.g. a different\n> > allocator would immediately make it incompatible.\n> \n> I don't think the allocator is an issue in libcamera.\n\nThis is a general argument in favor, not specific to libcamera, indeed. Although\nusers can still use different allocators, in which case they would be affected,\ne.g. `CameraManager::get()`.\n\n\n> \n> >\n> > In contrast to that using an `std::string_view` is better if\n> > NUL termination is not needed since no `std::string` construction\n> > is required, and in many cases it can be passed directly in registers.\n> \n> I had a go at this previously, and had very mixed feelings about the\n> result. I'll post a WIP series for discussion.\n\nWhat were the concerns? This change only considers a limited subset of all\n`const std::string&` parameters. For example, functions (constructors) where a\ncopy of the string made are excluded. Mostly the \"find-thing-by-name\" style\nfunctions are converted here.\n\n\nRegards,\nBarnabás Pőcze\n\n\n> \n> >\n> > Signed-off-by: Barnabás Pőcze <pobrn@protonmail.com>\n> > ---\n> >  include/libcamera/base/utils.h                     | 10 +++++-----\n> >  include/libcamera/camera_manager.h                 |  3 ++-\n> >  .../libcamera/internal/camera_sensor_properties.h  |  4 ++--\n> >  include/libcamera/internal/device_enumerator.h     |  3 ++-\n> >  include/libcamera/internal/formats.h               |  3 ++-\n> >  include/libcamera/internal/media_device.h          |  7 ++++---\n> >  include/libcamera/internal/pipeline_handler.h      |  3 ++-\n> >  include/libcamera/internal/v4l2_subdevice.h        |  3 ++-\n> >  include/libcamera/internal/v4l2_videodevice.h      |  3 ++-\n> >  include/libcamera/pixel_format.h                   |  3 ++-\n> >  src/apps/cam/capture_script.cpp                    |  2 +-\n> >  src/apps/cam/capture_script.h                      |  3 ++-\n> >  src/apps/cam/drm.cpp                               |  8 ++++----\n> >  src/apps/cam/drm.h                                 |  9 +++++----\n> >  src/ipa/libipa/camera_sensor_helper.cpp            |  2 +-\n> >  src/ipa/libipa/camera_sensor_helper.h              |  3 ++-\n> >  src/ipa/libipa/module.cpp                          |  2 +-\n> >  src/ipa/libipa/module.h                            |  4 ++--\n> >  src/libcamera/base/utils.cpp                       |  8 ++++----\n> >  src/libcamera/camera_manager.cpp                   |  2 +-\n> >  src/libcamera/device_enumerator.cpp                |  2 +-\n> >  src/libcamera/device_enumerator_udev.cpp           |  2 +-\n> >  src/libcamera/formats.cpp                          |  2 +-\n> >  src/libcamera/media_device.cpp                     | 14 +++++++-------\n> >  src/libcamera/pipeline_handler.cpp                 |  2 +-\n> >  src/libcamera/pixel_format.cpp                     |  2 +-\n> >  src/libcamera/sensor/camera_sensor_properties.cpp  |  4 ++--\n> >  src/libcamera/v4l2_subdevice.cpp                   |  2 +-\n> >  src/libcamera/v4l2_videodevice.cpp                 |  2 +-\n> >  src/py/libcamera/py_camera_manager.h               |  2 +-\n> >  src/py/libcamera/py_main.cpp                       |  2 +-\n> >  31 files changed, 66 insertions(+), 55 deletions(-)\n> >\n> > diff --git a/include/libcamera/base/utils.h b/include/libcamera/base/utils.h\n> > index 780aeda6a..3b8b3dea9 100644\n> > --- a/include/libcamera/base/utils.h\n> > +++ b/include/libcamera/base/utils.h\n> > @@ -38,7 +38,7 @@ namespace utils {\n> >  const char *basename(const char *path);\n> >\n> >  char *secure_getenv(const char *name);\n> > -std::string dirname(const std::string &path);\n> > +std::string dirname(std::string_view path);\n> >\n> >  template<typename T>\n> >  std::vector<typename T::key_type> map_keys(const T &map)\n> > @@ -143,7 +143,7 @@ size_t strlcpy(char *dst, const char *src, size_t size);\n> >\n> >  #ifndef __DOXYGEN__\n> >  template<typename Container, typename UnaryOp>\n> > -std::string join(const Container &items, const std::string &sep, UnaryOp op)\n> > +std::string join(const Container &items, std::string_view sep, UnaryOp op)\n> >  {\n> >  \tstd::ostringstream ss;\n> >  \tbool first = true;\n> > @@ -162,7 +162,7 @@ std::string join(const Container &items, const std::string &sep, UnaryOp op)\n> >  }\n> >\n> >  template<typename Container>\n> > -std::string join(const Container &items, const std::string &sep)\n> > +std::string join(const Container &items, std::string_view sep)\n> >  {\n> >  \tstd::ostringstream ss;\n> >  \tbool first = true;\n> > @@ -181,7 +181,7 @@ std::string join(const Container &items, const std::string &sep)\n> >  }\n> >  #else\n> >  template<typename Container, typename UnaryOp>\n> > -std::string join(const Container &items, const std::string &sep, UnaryOp op = nullptr);\n> > +std::string join(const Container &items, std::string_view sep, UnaryOp op = nullptr);\n> >  #endif\n> >\n> >  namespace details {\n> > @@ -240,7 +240,7 @@ private:\n> >\n> >  details::StringSplitter split(const std::string &str, const std::string &delim);\n> >\n> > -std::string toAscii(const std::string &str);\n> > +std::string toAscii(std::string_view str);\n> >\n> >  std::string libcameraBuildPath();\n> >  std::string libcameraSourcePath();\n> > diff --git a/include/libcamera/camera_manager.h b/include/libcamera/camera_manager.h\n> > index b50df7825..27835500f 100644\n> > --- a/include/libcamera/camera_manager.h\n> > +++ b/include/libcamera/camera_manager.h\n> > @@ -9,6 +9,7 @@\n> >\n> >  #include <memory>\n> >  #include <string>\n> > +#include <string_view>\n> >  #include <sys/types.h>\n> >  #include <vector>\n> >\n> > @@ -31,7 +32,7 @@ public:\n> >  \tvoid stop();\n> >\n> >  \tstd::vector<std::shared_ptr<Camera>> cameras() const;\n> > -\tstd::shared_ptr<Camera> get(const std::string &id);\n> > +\tstd::shared_ptr<Camera> get(std::string_view id);\n> >\n> >  \tstatic const std::string &version() { return version_; }\n> >\n> > diff --git a/include/libcamera/internal/camera_sensor_properties.h b/include/libcamera/internal/camera_sensor_properties.h\n> > index d7d4dab62..b44093906 100644\n> > --- a/include/libcamera/internal/camera_sensor_properties.h\n> > +++ b/include/libcamera/internal/camera_sensor_properties.h\n> > @@ -9,7 +9,7 @@\n> >\n> >  #include <map>\n> >  #include <stdint.h>\n> > -#include <string>\n> > +#include <string_view>\n> >\n> >  #include <libcamera/control_ids.h>\n> >  #include <libcamera/geometry.h>\n> > @@ -24,7 +24,7 @@ struct CameraSensorProperties {\n> >  \t\tuint8_t hblankDelay;\n> >  \t};\n> >\n> > -\tstatic const CameraSensorProperties *get(const std::string &sensor);\n> > +\tstatic const CameraSensorProperties *get(std::string_view sensor);\n> >\n> >  \tSize unitCellSize;\n> >  \tstd::map<controls::draft::TestPatternModeEnum, int32_t> testPatternModes;\n> > diff --git a/include/libcamera/internal/device_enumerator.h b/include/libcamera/internal/device_enumerator.h\n> > index db3532a98..eecc39cfb 100644\n> > --- a/include/libcamera/internal/device_enumerator.h\n> > +++ b/include/libcamera/internal/device_enumerator.h\n> > @@ -9,6 +9,7 @@\n> >\n> >  #include <memory>\n> >  #include <string>\n> > +#include <string_view>\n> >  #include <vector>\n> >\n> >  #include <libcamera/base/signal.h>\n> > @@ -48,7 +49,7 @@ public:\n> >  protected:\n> >  \tstd::unique_ptr<MediaDevice> createDevice(const std::string &deviceNode);\n> >  \tvoid addDevice(std::unique_ptr<MediaDevice> media);\n> > -\tvoid removeDevice(const std::string &deviceNode);\n> > +\tvoid removeDevice(std::string_view deviceNode);\n> >\n> >  private:\n> >  \tstd::vector<std::shared_ptr<MediaDevice>> devices_;\n> > diff --git a/include/libcamera/internal/formats.h b/include/libcamera/internal/formats.h\n> > index 6a3e9c16a..bd7ac6ed1 100644\n> > --- a/include/libcamera/internal/formats.h\n> > +++ b/include/libcamera/internal/formats.h\n> > @@ -8,6 +8,7 @@\n> >  #pragma once\n> >\n> >  #include <array>\n> > +#include <string_view>\n> >  #include <vector>\n> >\n> >  #include <libcamera/geometry.h>\n> > @@ -35,7 +36,7 @@ public:\n> >\n> >  \tstatic const PixelFormatInfo &info(const PixelFormat &format);\n> >  \tstatic const PixelFormatInfo &info(const V4L2PixelFormat &format);\n> > -\tstatic const PixelFormatInfo &info(const std::string &name);\n> > +\tstatic const PixelFormatInfo &info(std::string_view name);\n> >\n> >  \tunsigned int stride(unsigned int width, unsigned int plane,\n> >  \t\t\t    unsigned int align = 1) const;\n> > diff --git a/include/libcamera/internal/media_device.h b/include/libcamera/internal/media_device.h\n> > index e412d3a0b..91610a7aa 100644\n> > --- a/include/libcamera/internal/media_device.h\n> > +++ b/include/libcamera/internal/media_device.h\n> > @@ -9,6 +9,7 @@\n> >\n> >  #include <map>\n> >  #include <string>\n> > +#include <string_view>\n> >  #include <vector>\n> >\n> >  #include <linux/media.h>\n> > @@ -44,10 +45,10 @@ public:\n> >  \tunsigned int hwRevision() const { return hwRevision_; }\n> >\n> >  \tconst std::vector<MediaEntity *> &entities() const { return entities_; }\n> > -\tMediaEntity *getEntityByName(const std::string &name) const;\n> > +\tMediaEntity *getEntityByName(std::string_view name) const;\n> >\n> > -\tMediaLink *link(const std::string &sourceName, unsigned int sourceIdx,\n> > -\t\t\tconst std::string &sinkName, unsigned int sinkIdx);\n> > +\tMediaLink *link(std::string_view sourceName, unsigned int sourceIdx,\n> > +\t\t\tstd::string_view sinkName, unsigned int sinkIdx);\n> >  \tMediaLink *link(const MediaEntity *source, unsigned int sourceIdx,\n> >  \t\t\tconst MediaEntity *sink, unsigned int sinkIdx);\n> >  \tMediaLink *link(const MediaPad *source, const MediaPad *sink);\n> > diff --git a/include/libcamera/internal/pipeline_handler.h b/include/libcamera/internal/pipeline_handler.h\n> > index fb28a18d0..45eafce9b 100644\n> > --- a/include/libcamera/internal/pipeline_handler.h\n> > +++ b/include/libcamera/internal/pipeline_handler.h\n> > @@ -10,6 +10,7 @@\n> >  #include <memory>\n> >  #include <queue>\n> >  #include <string>\n> > +#include <string_view>\n> >  #include <sys/types.h>\n> >  #include <vector>\n> >\n> > @@ -112,7 +113,7 @@ public:\n> >  \tconst std::string &name() const { return name_; }\n> >\n> >  \tstatic std::vector<PipelineHandlerFactoryBase *> &factories();\n> > -\tstatic const PipelineHandlerFactoryBase *getFactoryByName(const std::string &name);\n> > +\tstatic const PipelineHandlerFactoryBase *getFactoryByName(std::string_view name);\n> >\n> >  private:\n> >  \tstatic void registerType(PipelineHandlerFactoryBase *factory);\n> > diff --git a/include/libcamera/internal/v4l2_subdevice.h b/include/libcamera/internal/v4l2_subdevice.h\n> > index 194382f84..d17365e14 100644\n> > --- a/include/libcamera/internal/v4l2_subdevice.h\n> > +++ b/include/libcamera/internal/v4l2_subdevice.h\n> > @@ -11,6 +11,7 @@\n> >  #include <optional>\n> >  #include <ostream>\n> >  #include <string>\n> > +#include <string_view>\n> >  #include <vector>\n> >\n> >  #include <linux/v4l2-subdev.h>\n> > @@ -161,7 +162,7 @@ public:\n> >  \tconst V4L2SubdeviceCapability &caps() const { return caps_; }\n> >\n> >  \tstatic std::unique_ptr<V4L2Subdevice>\n> > -\tfromEntityName(const MediaDevice *media, const std::string &entity);\n> > +\tfromEntityName(const MediaDevice *media, std::string_view entity);\n> >\n> >  protected:\n> >  \tstd::string logPrefix() const override;\n> > diff --git a/include/libcamera/internal/v4l2_videodevice.h b/include/libcamera/internal/v4l2_videodevice.h\n> > index f021c2a01..c256e82af 100644\n> > --- a/include/libcamera/internal/v4l2_videodevice.h\n> > +++ b/include/libcamera/internal/v4l2_videodevice.h\n> > @@ -14,6 +14,7 @@\n> >  #include <ostream>\n> >  #include <stdint.h>\n> >  #include <string>\n> > +#include <string_view>\n> >  #include <unordered_set>\n> >  #include <vector>\n> >\n> > @@ -228,7 +229,7 @@ public:\n> >  \tSignal<> dequeueTimeout;\n> >\n> >  \tstatic std::unique_ptr<V4L2VideoDevice>\n> > -\tfromEntityName(const MediaDevice *media, const std::string &entity);\n> > +\tfromEntityName(const MediaDevice *media, std::string_view entity);\n> >\n> >  \tV4L2PixelFormat toV4L2PixelFormat(const PixelFormat &pixelFormat) const;\n> >\n> > diff --git a/include/libcamera/pixel_format.h b/include/libcamera/pixel_format.h\n> > index 1b4d8c7c8..874b2528b 100644\n> > --- a/include/libcamera/pixel_format.h\n> > +++ b/include/libcamera/pixel_format.h\n> > @@ -10,6 +10,7 @@\n> >  #include <ostream>\n> >  #include <stdint.h>\n> >  #include <string>\n> > +#include <string_view>\n> >\n> >  namespace libcamera {\n> >\n> > @@ -38,7 +39,7 @@ public:\n> >\n> >  \tstd::string toString() const;\n> >\n> > -\tstatic PixelFormat fromString(const std::string &name);\n> > +\tstatic PixelFormat fromString(std::string_view name);\n> >\n> >  private:\n> >  \tuint32_t fourcc_;\n> > diff --git a/src/apps/cam/capture_script.cpp b/src/apps/cam/capture_script.cpp\n> > index fc1dfa75f..d4760ea78 100644\n> > --- a/src/apps/cam/capture_script.cpp\n> > +++ b/src/apps/cam/capture_script.cpp\n> > @@ -432,7 +432,7 @@ std::vector<std::string> CaptureScript::parseSingleArray()\n> >  \t}\n> >  }\n> >\n> > -void CaptureScript::unpackFailure(const ControlId *id, const std::string &repr)\n> > +void CaptureScript::unpackFailure(const ControlId *id, std::string_view repr)\n> >  {\n> >  \tstatic const std::map<unsigned int, const char *> typeNames = {\n> >  \t\t{ ControlTypeNone, \"none\" },\n> > diff --git a/src/apps/cam/capture_script.h b/src/apps/cam/capture_script.h\n> > index 294b92036..fb40371f2 100644\n> > --- a/src/apps/cam/capture_script.h\n> > +++ b/src/apps/cam/capture_script.h\n> > @@ -10,6 +10,7 @@\n> >  #include <map>\n> >  #include <memory>\n> >  #include <string>\n> > +#include <string_view>\n> >\n> >  #include <libcamera/camera.h>\n> >  #include <libcamera/controls.h>\n> > @@ -67,7 +68,7 @@ private:\n> >  \tstd::vector<std::string> parseSingleArray();\n> >\n> >  \tvoid unpackFailure(const libcamera::ControlId *id,\n> > -\t\t\t   const std::string &repr);\n> > +\t\t\t   std::string_view repr);\n> >  \tlibcamera::ControlValue unpackControl(const libcamera::ControlId *id);\n> >  \tlibcamera::Rectangle unpackRectangle(const std::vector<std::string> &strVec);\n> >  };\n> > diff --git a/src/apps/cam/drm.cpp b/src/apps/cam/drm.cpp\n> > index 47bbb6b05..fd9c59ec4 100644\n> > --- a/src/apps/cam/drm.cpp\n> > +++ b/src/apps/cam/drm.cpp\n> > @@ -57,7 +57,7 @@ Object::~Object()\n> >  {\n> >  }\n> >\n> > -const Property *Object::property(const std::string &name) const\n> > +const Property *Object::property(std::string_view name) const\n> >  {\n> >  \tfor (const PropertyValue &pv : properties_) {\n> >  \t\tconst Property *property = static_cast<const Property *>(dev_->object(pv.id()));\n> > @@ -68,7 +68,7 @@ const Property *Object::property(const std::string &name) const\n> >  \treturn nullptr;\n> >  }\n> >\n> > -const PropertyValue *Object::propertyValue(const std::string &name) const\n> > +const PropertyValue *Object::propertyValue(std::string_view name) const\n> >  {\n> >  \tfor (const PropertyValue &pv : properties_) {\n> >  \t\tconst Property *property = static_cast<const Property *>(dev_->object(pv.id()));\n> > @@ -320,7 +320,7 @@ AtomicRequest::~AtomicRequest()\n> >  \t\tdrmModeAtomicFree(request_);\n> >  }\n> >\n> > -int AtomicRequest::addProperty(const Object *object, const std::string &property,\n> > +int AtomicRequest::addProperty(const Object *object, std::string_view property,\n> >  \t\t\t       uint64_t value)\n> >  {\n> >  \tif (!valid_)\n> > @@ -335,7 +335,7 @@ int AtomicRequest::addProperty(const Object *object, const std::string &property\n> >  \treturn addProperty(object->id(), prop->id(), value);\n> >  }\n> >\n> > -int AtomicRequest::addProperty(const Object *object, const std::string &property,\n> > +int AtomicRequest::addProperty(const Object *object, std::string_view property,\n> >  \t\t\t       std::unique_ptr<Blob> blob)\n> >  {\n> >  \tif (!valid_)\n> > diff --git a/src/apps/cam/drm.h b/src/apps/cam/drm.h\n> > index 1ba83b6eb..aa1b06400 100644\n> > --- a/src/apps/cam/drm.h\n> > +++ b/src/apps/cam/drm.h\n> > @@ -13,6 +13,7 @@\n> >  #include <memory>\n> >  #include <stdint.h>\n> >  #include <string>\n> > +#include <string_view>\n> >  #include <vector>\n> >\n> >  #include <libcamera/base/signal.h>\n> > @@ -57,8 +58,8 @@ public:\n> >  \tuint32_t id() const { return id_; }\n> >  \tType type() const { return type_; }\n> >\n> > -\tconst Property *property(const std::string &name) const;\n> > -\tconst PropertyValue *propertyValue(const std::string &name) const;\n> > +\tconst Property *property(std::string_view name) const;\n> > +\tconst PropertyValue *propertyValue(std::string_view name) const;\n> >  \tconst std::vector<PropertyValue> &properties() const { return properties_; }\n> >\n> >  protected:\n> > @@ -260,9 +261,9 @@ public:\n> >  \tDevice *device() const { return dev_; }\n> >  \tbool isValid() const { return valid_; }\n> >\n> > -\tint addProperty(const Object *object, const std::string &property,\n> > +\tint addProperty(const Object *object, std::string_view property,\n> >  \t\t\tuint64_t value);\n> > -\tint addProperty(const Object *object, const std::string &property,\n> > +\tint addProperty(const Object *object, std::string_view property,\n> >  \t\t\tstd::unique_ptr<Blob> blob);\n> >  \tint commit(unsigned int flags = 0);\n> >\n> > diff --git a/src/ipa/libipa/camera_sensor_helper.cpp b/src/ipa/libipa/camera_sensor_helper.cpp\n> > index 7c66cd57d..4ed050b14 100644\n> > --- a/src/ipa/libipa/camera_sensor_helper.cpp\n> > +++ b/src/ipa/libipa/camera_sensor_helper.cpp\n> > @@ -240,7 +240,7 @@ CameraSensorHelperFactoryBase::CameraSensorHelperFactoryBase(const std::string n\n> >   * corresponding to the named factory or a null pointer if no such factory\n> >   * exists\n> >   */\n> > -std::unique_ptr<CameraSensorHelper> CameraSensorHelperFactoryBase::create(const std::string &name)\n> > +std::unique_ptr<CameraSensorHelper> CameraSensorHelperFactoryBase::create(std::string_view name)\n> >  {\n> >  \tconst std::vector<CameraSensorHelperFactoryBase *> &factories =\n> >  \t\tCameraSensorHelperFactoryBase::factories();\n> > diff --git a/src/ipa/libipa/camera_sensor_helper.h b/src/ipa/libipa/camera_sensor_helper.h\n> > index a9300a64f..eedc80114 100644\n> > --- a/src/ipa/libipa/camera_sensor_helper.h\n> > +++ b/src/ipa/libipa/camera_sensor_helper.h\n> > @@ -11,6 +11,7 @@\n> >  #include <optional>\n> >  #include <stdint.h>\n> >  #include <string>\n> > +#include <string_view>\n> >  #include <variant>\n> >  #include <vector>\n> >\n> > @@ -56,7 +57,7 @@ public:\n> >  \tCameraSensorHelperFactoryBase(const std::string name);\n> >  \tvirtual ~CameraSensorHelperFactoryBase() = default;\n> >\n> > -\tstatic std::unique_ptr<CameraSensorHelper> create(const std::string &name);\n> > +\tstatic std::unique_ptr<CameraSensorHelper> create(std::string_view name);\n> >\n> >  \tstatic std::vector<CameraSensorHelperFactoryBase *> &factories();\n> >\n> > diff --git a/src/ipa/libipa/module.cpp b/src/ipa/libipa/module.cpp\n> > index 64ca91419..91fb588e7 100644\n> > --- a/src/ipa/libipa/module.cpp\n> > +++ b/src/ipa/libipa/module.cpp\n> > @@ -107,7 +107,7 @@ namespace ipa {\n> >   */\n> >\n> >  /**\n> > - * \\fn Module::createAlgorithm(const std::string &name)\n> > + * \\fn Module::createAlgorithm(std::string_view name)\n> >   * \\brief Create an instance of an Algorithm by name\n> >   * \\param[in] name The algorithm name\n> >   *\n> > diff --git a/src/ipa/libipa/module.h b/src/ipa/libipa/module.h\n> > index 0fb51916f..62c700a64 100644\n> > --- a/src/ipa/libipa/module.h\n> > +++ b/src/ipa/libipa/module.h\n> > @@ -9,7 +9,7 @@\n> >\n> >  #include <list>\n> >  #include <memory>\n> > -#include <string>\n> > +#include <string_view>\n> >  #include <vector>\n> >\n> >  #include <libcamera/base/log.h>\n> > @@ -95,7 +95,7 @@ private:\n> >  \t\treturn 0;\n> >  \t}\n> >\n> > -\tstatic std::unique_ptr<Algorithm<Module>> createAlgorithm(const std::string &name)\n> > +\tstatic std::unique_ptr<Algorithm<Module>> createAlgorithm(std::string_view name)\n> >  \t{\n> >  \t\tfor (const AlgorithmFactoryBase<Module> *factory : factories()) {\n> >  \t\t\tif (factory->name() == name)\n> > diff --git a/src/libcamera/base/utils.cpp b/src/libcamera/base/utils.cpp\n> > index bcfc1941a..de6e2afd6 100644\n> > --- a/src/libcamera/base/utils.cpp\n> > +++ b/src/libcamera/base/utils.cpp\n> > @@ -80,7 +80,7 @@ char *secure_getenv(const char *name)\n> >   *\n> >   * \\return A string of the directory component of the path\n> >   */\n> > -std::string dirname(const std::string &path)\n> > +std::string dirname(std::string_view path)\n> >  {\n> >  \tif (path.empty())\n> >  \t\treturn \".\";\n> > @@ -116,7 +116,7 @@ std::string dirname(const std::string &path)\n> >  \t\tpos--;\n> >  \t}\n> >\n> > -\treturn path.substr(0, pos + 1);\n> > +\treturn std::string(path.substr(0, pos + 1));\n> >  }\n> >\n> >  /**\n> > @@ -278,7 +278,7 @@ std::string details::StringSplitter::iterator::operator*() const\n> >\n> >  /**\n> >   * \\fn template<typename Container, typename UnaryOp> \\\n> > - * std::string utils::join(const Container &items, const std::string &sep, UnaryOp op)\n> > + * std::string utils::join(const Container &items, std::string_view sep, UnaryOp op)\n> >   * \\brief Join elements of a container in a string with a separator\n> >   * \\param[in] items The container\n> >   * \\param[in] sep The separator to add between elements\n> > @@ -319,7 +319,7 @@ details::StringSplitter split(const std::string &str, const std::string &delim)\n> >   *\n> >   * \\return A string equal to \\a str stripped out of all non-ASCII characters\n> >   */\n> > -std::string toAscii(const std::string &str)\n> > +std::string toAscii(std::string_view str)\n> >  {\n> >  \tstd::string ret;\n> >  \tfor (const char &c : str)\n> > diff --git a/src/libcamera/camera_manager.cpp b/src/libcamera/camera_manager.cpp\n> > index 87e6717ec..179fa37ea 100644\n> > --- a/src/libcamera/camera_manager.cpp\n> > +++ b/src/libcamera/camera_manager.cpp\n> > @@ -382,7 +382,7 @@ std::vector<std::shared_ptr<Camera>> CameraManager::cameras() const\n> >   *\n> >   * \\return Shared pointer to Camera object or nullptr if camera not found\n> >   */\n> > -std::shared_ptr<Camera> CameraManager::get(const std::string &id)\n> > +std::shared_ptr<Camera> CameraManager::get(std::string_view id)\n> >  {\n> >  \tPrivate *const d = _d();\n> >\n> > diff --git a/src/libcamera/device_enumerator.cpp b/src/libcamera/device_enumerator.cpp\n> > index ae17862f6..8744a90f3 100644\n> > --- a/src/libcamera/device_enumerator.cpp\n> > +++ b/src/libcamera/device_enumerator.cpp\n> > @@ -272,7 +272,7 @@ void DeviceEnumerator::addDevice(std::unique_ptr<MediaDevice> media)\n> >   * enumerator with addDevice(). The media device's MediaDevice::disconnected\n> >   * signal is emitted.\n> >   */\n> > -void DeviceEnumerator::removeDevice(const std::string &deviceNode)\n> > +void DeviceEnumerator::removeDevice(std::string_view deviceNode)\n> >  {\n> >  \tstd::shared_ptr<MediaDevice> media;\n> >\n> > diff --git a/src/libcamera/device_enumerator_udev.cpp b/src/libcamera/device_enumerator_udev.cpp\n> > index 4e20a3cc0..c330f30bc 100644\n> > --- a/src/libcamera/device_enumerator_udev.cpp\n> > +++ b/src/libcamera/device_enumerator_udev.cpp\n> > @@ -351,7 +351,7 @@ void DeviceEnumeratorUdev::udevNotify()\n> >  \t} else if (action == \"remove\") {\n> >  \t\tconst char *subsystem = udev_device_get_subsystem(dev);\n> >  \t\tif (subsystem && !strcmp(subsystem, \"media\"))\n> > -\t\t\tremoveDevice(std::string(deviceNode));\n> > +\t\t\tremoveDevice(deviceNode);\n> >  \t}\n> >\n> >  \tudev_device_unref(dev);\n> > diff --git a/src/libcamera/formats.cpp b/src/libcamera/formats.cpp\n> > index bfcdfc089..112dfe66b 100644\n> > --- a/src/libcamera/formats.cpp\n> > +++ b/src/libcamera/formats.cpp\n> > @@ -1037,7 +1037,7 @@ const PixelFormatInfo &PixelFormatInfo::info(const V4L2PixelFormat &format)\n> >   * \\return The PixelFormatInfo describing the PixelFormat matching the\n> >   * \\a name if known, or an invalid PixelFormatInfo otherwise\n> >   */\n> > -const PixelFormatInfo &PixelFormatInfo::info(const std::string &name)\n> > +const PixelFormatInfo &PixelFormatInfo::info(std::string_view name)\n> >  {\n> >  \tfor (const auto &info : pixelFormatInfo) {\n> >  \t\tif (info.second.name == name)\n> > diff --git a/src/libcamera/media_device.cpp b/src/libcamera/media_device.cpp\n> > index d71dad74d..131b34446 100644\n> > --- a/src/libcamera/media_device.cpp\n> > +++ b/src/libcamera/media_device.cpp\n> > @@ -331,7 +331,7 @@ done:\n> >   * \\param[in] name The entity name\n> >   * \\return The entity with \\a name, or nullptr if no such entity is found\n> >   */\n> > -MediaEntity *MediaDevice::getEntityByName(const std::string &name) const\n> > +MediaEntity *MediaDevice::getEntityByName(std::string_view name) const\n> >  {\n> >  \tfor (MediaEntity *e : entities_)\n> >  \t\tif (e->name() == name)\n> > @@ -359,8 +359,8 @@ MediaEntity *MediaDevice::getEntityByName(const std::string &name) const\n> >   * \\return The link that connects the two pads, or nullptr if no such a link\n> >   * exists\n> >   */\n> > -MediaLink *MediaDevice::link(const std::string &sourceName, unsigned int sourceIdx,\n> > -\t\t\t     const std::string &sinkName, unsigned int sinkIdx)\n> > +MediaLink *MediaDevice::link(std::string_view sourceName, unsigned int sourceIdx,\n> > +\t\t\t     std::string_view sinkName, unsigned int sinkIdx)\n> >  {\n> >  \tconst MediaEntity *source = getEntityByName(sourceName);\n> >  \tconst MediaEntity *sink = getEntityByName(sinkName);\n> > @@ -382,8 +382,8 @@ MediaLink *MediaDevice::link(const std::string &sourceName, unsigned int sourceI\n> >   * entity \\a source, to the pad at index \\a sinkIdx of the sink entity \\a\n> >   * sink, if any.\n> >   *\n> > - * \\sa link(const std::string &sourceName, unsigned int sourceIdx,\n> > - *          const std::string &sinkName, unsigned int sinkIdx)\n> > + * \\sa link(std::string_view sourceName, unsigned int sourceIdx,\n> > + *          std::string_view sinkName, unsigned int sinkIdx)\n> >   * \\sa link(const MediaPad *source, const MediaPad *sink)\n> >   *\n> >   * \\return The link that connects the two pads, or nullptr if no such a link\n> > @@ -406,8 +406,8 @@ MediaLink *MediaDevice::link(const MediaEntity *source, unsigned int sourceIdx,\n> >   * \\param[in] source The source pad\n> >   * \\param[in] sink The sink pad\n> >   *\n> > - * \\sa link(const std::string &sourceName, unsigned int sourceIdx,\n> > - *          const std::string &sinkName, unsigned int sinkIdx)\n> > + * \\sa link(std::string_view sourceName, unsigned int sourceIdx,\n> > + *          std::string_view sinkName, unsigned int sinkIdx)\n> >   * \\sa link(const MediaEntity *source, unsigned int sourceIdx,\n> >   *          const MediaEntity *sink, unsigned int sinkIdx)\n> >   *\n> > diff --git a/src/libcamera/pipeline_handler.cpp b/src/libcamera/pipeline_handler.cpp\n> > index caa5c20e7..6b395c666 100644\n> > --- a/src/libcamera/pipeline_handler.cpp\n> > +++ b/src/libcamera/pipeline_handler.cpp\n> > @@ -852,7 +852,7 @@ std::vector<PipelineHandlerFactoryBase *> &PipelineHandlerFactoryBase::factories\n> >   * \\param[in] name The pipeline handler name\n> >   * \\return The factory of the pipeline with name \\a name, or nullptr if not found\n> >   */\n> > -const PipelineHandlerFactoryBase *PipelineHandlerFactoryBase::getFactoryByName(const std::string &name)\n> > +const PipelineHandlerFactoryBase *PipelineHandlerFactoryBase::getFactoryByName(std::string_view name)\n> >  {\n> >  \tconst std::vector<PipelineHandlerFactoryBase *> &factories =\n> >  \t\tPipelineHandlerFactoryBase::factories();\n> > diff --git a/src/libcamera/pixel_format.cpp b/src/libcamera/pixel_format.cpp\n> > index 314179a81..22f1520fd 100644\n> > --- a/src/libcamera/pixel_format.cpp\n> > +++ b/src/libcamera/pixel_format.cpp\n> > @@ -135,7 +135,7 @@ std::string PixelFormat::toString() const\n> >   * \\return The PixelFormat represented by the \\a name if known, or an\n> >   * invalid pixel format otherwise.\n> >   */\n> > -PixelFormat PixelFormat::fromString(const std::string &name)\n> > +PixelFormat PixelFormat::fromString(std::string_view name)\n> >  {\n> >  \treturn PixelFormatInfo::info(name).format;\n> >  }\n> > diff --git a/src/libcamera/sensor/camera_sensor_properties.cpp b/src/libcamera/sensor/camera_sensor_properties.cpp\n> > index 2b06c5a1a..4283cacfa 100644\n> > --- a/src/libcamera/sensor/camera_sensor_properties.cpp\n> > +++ b/src/libcamera/sensor/camera_sensor_properties.cpp\n> > @@ -78,9 +78,9 @@ LOG_DEFINE_CATEGORY(CameraSensorProperties)\n> >   * \\return A pointer to the CameraSensorProperties instance associated with a sensor\n> >   * or nullptr if the sensor is not supported\n> >   */\n> > -const CameraSensorProperties *CameraSensorProperties::get(const std::string &sensor)\n> > +const CameraSensorProperties *CameraSensorProperties::get(std::string_view sensor)\n> >  {\n> > -\tstatic const std::map<std::string, const CameraSensorProperties> sensorProps = {\n> > +\tstatic const std::map<std::string_view, const CameraSensorProperties> sensorProps = {\n> >  \t\t{ \"ar0144\", {\n> >  \t\t\t.unitCellSize = { 3000, 3000 },\n> >  \t\t\t.testPatternModes = {\n> > diff --git a/src/libcamera/v4l2_subdevice.cpp b/src/libcamera/v4l2_subdevice.cpp\n> > index 3a0d075f9..7e85b33be 100644\n> > --- a/src/libcamera/v4l2_subdevice.cpp\n> > +++ b/src/libcamera/v4l2_subdevice.cpp\n> > @@ -1688,7 +1688,7 @@ const std::string &V4L2Subdevice::model()\n> >   */\n> >  std::unique_ptr<V4L2Subdevice>\n> >  V4L2Subdevice::fromEntityName(const MediaDevice *media,\n> > -\t\t\t      const std::string &entity)\n> > +\t\t\t      std::string_view entity)\n> >  {\n> >  \tMediaEntity *mediaEntity = media->getEntityByName(entity);\n> >  \tif (!mediaEntity)\n> > diff --git a/src/libcamera/v4l2_videodevice.cpp b/src/libcamera/v4l2_videodevice.cpp\n> > index a5cf67845..834a1bd0d 100644\n> > --- a/src/libcamera/v4l2_videodevice.cpp\n> > +++ b/src/libcamera/v4l2_videodevice.cpp\n> > @@ -2077,7 +2077,7 @@ void V4L2VideoDevice::watchdogExpired()\n> >   */\n> >  std::unique_ptr<V4L2VideoDevice>\n> >  V4L2VideoDevice::fromEntityName(const MediaDevice *media,\n> > -\t\t\t\tconst std::string &entity)\n> > +\t\t\t\tstd::string_view entity)\n> >  {\n> >  \tMediaEntity *mediaEntity = media->getEntityByName(entity);\n> >  \tif (!mediaEntity)\n> > diff --git a/src/py/libcamera/py_camera_manager.h b/src/py/libcamera/py_camera_manager.h\n> > index 3574db236..af69b915e 100644\n> > --- a/src/py/libcamera/py_camera_manager.h\n> > +++ b/src/py/libcamera/py_camera_manager.h\n> > @@ -20,7 +20,7 @@ public:\n> >  \t~PyCameraManager();\n> >\n> >  \tpybind11::list cameras();\n> > -\tstd::shared_ptr<Camera> get(const std::string &name) { return cameraManager_->get(name); }\n> > +\tstd::shared_ptr<Camera> get(std::string_view name) { return cameraManager_->get(name); }\n> >\n> >  \tstatic const std::string &version() { return CameraManager::version(); }\n> >\n> > diff --git a/src/py/libcamera/py_main.cpp b/src/py/libcamera/py_main.cpp\n> > index 441a70ab4..820768c24 100644\n> > --- a/src/py/libcamera/py_main.cpp\n> > +++ b/src/py/libcamera/py_main.cpp\n> > @@ -510,7 +510,7 @@ PYBIND11_MODULE(_libcamera, m)\n> >  \tpyPixelFormat\n> >  \t\t.def(py::init<>())\n> >  \t\t.def(py::init<uint32_t, uint64_t>())\n> > -\t\t.def(py::init<>([](const std::string &str) {\n> > +\t\t.def(py::init<>([](std::string_view str) {\n> >  \t\t\treturn PixelFormat::fromString(str);\n> >  \t\t}))\n> >  \t\t.def_property_readonly(\"fourcc\", &PixelFormat::fourcc)\n> \n> --\n> Regards,\n> \n> Laurent Pinchart\n>","headers":{"Return-Path":"<libcamera-devel-bounces@lists.libcamera.org>","X-Original-To":"parsemail@patchwork.libcamera.org","Delivered-To":"parsemail@patchwork.libcamera.org","Received":["from lancelot.ideasonboard.com (lancelot.ideasonboard.com\n\t[92.243.16.209])\n\tby patchwork.libcamera.org (Postfix) with ESMTPS id E4BFEC32F5\n\tfor <parsemail@patchwork.libcamera.org>;\n\tSun, 15 Dec 2024 22:46:44 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id EE38567F27;\n\tSun, 15 Dec 2024 23:46:43 +0100 (CET)","from mail-4316.protonmail.ch (mail-4316.protonmail.ch\n\t[185.70.43.16])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 605B067F1B\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tSun, 15 Dec 2024 23:46:42 +0100 (CET)"],"Authentication-Results":"lancelot.ideasonboard.com;\n\tdkim=fail reason=\"signature verification failed\" (2048-bit key;\n\tunprotected) header.d=protonmail.com header.i=@protonmail.com\n\theader.b=\"oqC5owxR\"; dkim-atps=neutral","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/relaxed; d=protonmail.com;\n\ts=protonmail3; t=1734302801; x=1734562001;\n\tbh=uSLosLoYdLo01I271lGCNU1IBOLbbXsHhxHRHwz0vOQ=;\n\th=Date:To:From:Cc:Subject:Message-ID:In-Reply-To:References:\n\tFeedback-ID:From:To:Cc:Date:Subject:Reply-To:Feedback-ID:\n\tMessage-ID:BIMI-Selector:List-Unsubscribe:List-Unsubscribe-Post;\n\tb=oqC5owxRp9rJHIIBEX7aaX/DLyaV3oQgnTBbk4J6YH3Ys/9YPs/djX8QBZNFA3Svu\n\ta9WwO27BZqvVw67wrqmhS3e31Cv6LN4IdDKadwy1oYwdECJNz/O8wDJ6F3UkJGITkS\n\tgU2AZxFKM+pp357zElBRhu6Gd2hpV4Nom7BxHHjvX2gbSgebtNv1P73BP4T+36OPHi\n\t9/AxL1qKFmC3sWsovVYPKBvpiNryZwsIA3/fykpp9a0PJf1Ur0dRGE9G9tc9kVcell\n\t7Y0f35JBjy17ROjdO3qvnsw1E77cRSfw664plq2Dqau+FllWvoO61qZCtQ9otAYCA4\n\tGE35D47W2IgmQ==","Date":"Sun, 15 Dec 2024 22:46:35 +0000","To":"Laurent Pinchart <laurent.pinchart@ideasonboard.com>","From":"=?utf-8?q?Barnab=C3=A1s_P=C5=91cze?= <pobrn@protonmail.com>","Cc":"libcamera-devel@lists.libcamera.org","Subject":"Re: [RFC PATCH v1] treewide: Prefer `std::string_view` over `const\n\tstd::string&` in parameters","Message-ID":"<ZhYd-vdQuuQt3zHES9ZrjP_B7Hg-a4_I1GF91qrXD6bvrqDdknz8eZD5dyBt5fIlLd-QrybBSaiGaG-ISVwnuxXkX4oilIm2gCPZ19mYbBY=@protonmail.com>","In-Reply-To":"<20241215205643.GQ9975@pendragon.ideasonboard.com>","References":"<20241215204802.850593-1-pobrn@protonmail.com>\n\t<20241215205643.GQ9975@pendragon.ideasonboard.com>","Feedback-ID":"20568564:user:proton","X-Pm-Message-ID":"b7c69a7f32e36f4c90f9b9665e875f14d03cf071","MIME-Version":"1.0","Content-Type":"text/plain; charset=utf-8","Content-Transfer-Encoding":"quoted-printable","X-BeenThere":"libcamera-devel@lists.libcamera.org","X-Mailman-Version":"2.1.29","Precedence":"list","List-Id":"<libcamera-devel.lists.libcamera.org>","List-Unsubscribe":"<https://lists.libcamera.org/options/libcamera-devel>,\n\t<mailto:libcamera-devel-request@lists.libcamera.org?subject=unsubscribe>","List-Archive":"<https://lists.libcamera.org/pipermail/libcamera-devel/>","List-Post":"<mailto:libcamera-devel@lists.libcamera.org>","List-Help":"<mailto:libcamera-devel-request@lists.libcamera.org?subject=help>","List-Subscribe":"<https://lists.libcamera.org/listinfo/libcamera-devel>,\n\t<mailto:libcamera-devel-request@lists.libcamera.org?subject=subscribe>","Errors-To":"libcamera-devel-bounces@lists.libcamera.org","Sender":"\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>"}},{"id":32744,"web_url":"https://patchwork.libcamera.org/comment/32744/","msgid":"<20241215231447.GB31078@pendragon.ideasonboard.com>","date":"2024-12-15T23:14:47","subject":"Re: [RFC PATCH v1] treewide: Prefer `std::string_view` over `const\n\tstd::string&` in parameters","submitter":{"id":2,"url":"https://patchwork.libcamera.org/api/people/2/","name":"Laurent Pinchart","email":"laurent.pinchart@ideasonboard.com"},"content":"On Sun, Dec 15, 2024 at 10:46:35PM +0000, Barnabás Pőcze wrote:\n> 2024. december 15., vasárnap 21:56 keltezéssel, Laurent Pinchart írta:\n> > On Sun, Dec 15, 2024 at 08:48:06PM +0000, Barnabás Pőcze wrote:\n> > > A parameter of type `const std::string&` is not the right choice in\n> > > almost all cases. It forces the caller to construct an `std::string`\n> > > if they don't already have one, and accessing its data requires\n> > > an extra indirection. Furthermore, `std::string` is just one\n> > > instantiation of `std::basic_string<>`, using e.g. a different\n> > > allocator would immediately make it incompatible.\n> > \n> > I don't think the allocator is an issue in libcamera.\n> \n> This is a general argument in favor, not specific to libcamera, indeed. Although\n> users can still use different allocators, in which case they would be affected,\n> e.g. `CameraManager::get()`.\n> \n> > > In contrast to that using an `std::string_view` is better if\n> > > NUL termination is not needed since no `std::string` construction\n> > > is required, and in many cases it can be passed directly in registers.\n> > \n> > I had a go at this previously, and had very mixed feelings about the\n> > result. I'll post a WIP series for discussion.\n> \n> What were the concerns?\n\nSee \"[RFC PATCH 0/8] libcamera: Use std::string_view\" :-) Let's discuss\nit there, as there's a patch in the series that attempts to document\nstd::string_view usage. I would like to agree on clear rules before we\nmake tree-wide changes.\n\n> This change only considers a limited subset of all\n> `const std::string&` parameters. For example, functions (constructors) where a\n> copy of the string made are excluded. Mostly the \"find-thing-by-name\" style\n> functions are converted here.\n> \n> > > Signed-off-by: Barnabás Pőcze <pobrn@protonmail.com>\n> > > ---\n> > >  include/libcamera/base/utils.h                     | 10 +++++-----\n> > >  include/libcamera/camera_manager.h                 |  3 ++-\n> > >  .../libcamera/internal/camera_sensor_properties.h  |  4 ++--\n> > >  include/libcamera/internal/device_enumerator.h     |  3 ++-\n> > >  include/libcamera/internal/formats.h               |  3 ++-\n> > >  include/libcamera/internal/media_device.h          |  7 ++++---\n> > >  include/libcamera/internal/pipeline_handler.h      |  3 ++-\n> > >  include/libcamera/internal/v4l2_subdevice.h        |  3 ++-\n> > >  include/libcamera/internal/v4l2_videodevice.h      |  3 ++-\n> > >  include/libcamera/pixel_format.h                   |  3 ++-\n> > >  src/apps/cam/capture_script.cpp                    |  2 +-\n> > >  src/apps/cam/capture_script.h                      |  3 ++-\n> > >  src/apps/cam/drm.cpp                               |  8 ++++----\n> > >  src/apps/cam/drm.h                                 |  9 +++++----\n> > >  src/ipa/libipa/camera_sensor_helper.cpp            |  2 +-\n> > >  src/ipa/libipa/camera_sensor_helper.h              |  3 ++-\n> > >  src/ipa/libipa/module.cpp                          |  2 +-\n> > >  src/ipa/libipa/module.h                            |  4 ++--\n> > >  src/libcamera/base/utils.cpp                       |  8 ++++----\n> > >  src/libcamera/camera_manager.cpp                   |  2 +-\n> > >  src/libcamera/device_enumerator.cpp                |  2 +-\n> > >  src/libcamera/device_enumerator_udev.cpp           |  2 +-\n> > >  src/libcamera/formats.cpp                          |  2 +-\n> > >  src/libcamera/media_device.cpp                     | 14 +++++++-------\n> > >  src/libcamera/pipeline_handler.cpp                 |  2 +-\n> > >  src/libcamera/pixel_format.cpp                     |  2 +-\n> > >  src/libcamera/sensor/camera_sensor_properties.cpp  |  4 ++--\n> > >  src/libcamera/v4l2_subdevice.cpp                   |  2 +-\n> > >  src/libcamera/v4l2_videodevice.cpp                 |  2 +-\n> > >  src/py/libcamera/py_camera_manager.h               |  2 +-\n> > >  src/py/libcamera/py_main.cpp                       |  2 +-\n> > >  31 files changed, 66 insertions(+), 55 deletions(-)\n> > >\n> > > diff --git a/include/libcamera/base/utils.h b/include/libcamera/base/utils.h\n> > > index 780aeda6a..3b8b3dea9 100644\n> > > --- a/include/libcamera/base/utils.h\n> > > +++ b/include/libcamera/base/utils.h\n> > > @@ -38,7 +38,7 @@ namespace utils {\n> > >  const char *basename(const char *path);\n> > >\n> > >  char *secure_getenv(const char *name);\n> > > -std::string dirname(const std::string &path);\n> > > +std::string dirname(std::string_view path);\n> > >\n> > >  template<typename T>\n> > >  std::vector<typename T::key_type> map_keys(const T &map)\n> > > @@ -143,7 +143,7 @@ size_t strlcpy(char *dst, const char *src, size_t size);\n> > >\n> > >  #ifndef __DOXYGEN__\n> > >  template<typename Container, typename UnaryOp>\n> > > -std::string join(const Container &items, const std::string &sep, UnaryOp op)\n> > > +std::string join(const Container &items, std::string_view sep, UnaryOp op)\n> > >  {\n> > >  \tstd::ostringstream ss;\n> > >  \tbool first = true;\n> > > @@ -162,7 +162,7 @@ std::string join(const Container &items, const std::string &sep, UnaryOp op)\n> > >  }\n> > >\n> > >  template<typename Container>\n> > > -std::string join(const Container &items, const std::string &sep)\n> > > +std::string join(const Container &items, std::string_view sep)\n> > >  {\n> > >  \tstd::ostringstream ss;\n> > >  \tbool first = true;\n> > > @@ -181,7 +181,7 @@ std::string join(const Container &items, const std::string &sep)\n> > >  }\n> > >  #else\n> > >  template<typename Container, typename UnaryOp>\n> > > -std::string join(const Container &items, const std::string &sep, UnaryOp op = nullptr);\n> > > +std::string join(const Container &items, std::string_view sep, UnaryOp op = nullptr);\n> > >  #endif\n> > >\n> > >  namespace details {\n> > > @@ -240,7 +240,7 @@ private:\n> > >\n> > >  details::StringSplitter split(const std::string &str, const std::string &delim);\n> > >\n> > > -std::string toAscii(const std::string &str);\n> > > +std::string toAscii(std::string_view str);\n> > >\n> > >  std::string libcameraBuildPath();\n> > >  std::string libcameraSourcePath();\n> > > diff --git a/include/libcamera/camera_manager.h b/include/libcamera/camera_manager.h\n> > > index b50df7825..27835500f 100644\n> > > --- a/include/libcamera/camera_manager.h\n> > > +++ b/include/libcamera/camera_manager.h\n> > > @@ -9,6 +9,7 @@\n> > >\n> > >  #include <memory>\n> > >  #include <string>\n> > > +#include <string_view>\n> > >  #include <sys/types.h>\n> > >  #include <vector>\n> > >\n> > > @@ -31,7 +32,7 @@ public:\n> > >  \tvoid stop();\n> > >\n> > >  \tstd::vector<std::shared_ptr<Camera>> cameras() const;\n> > > -\tstd::shared_ptr<Camera> get(const std::string &id);\n> > > +\tstd::shared_ptr<Camera> get(std::string_view id);\n> > >\n> > >  \tstatic const std::string &version() { return version_; }\n> > >\n> > > diff --git a/include/libcamera/internal/camera_sensor_properties.h b/include/libcamera/internal/camera_sensor_properties.h\n> > > index d7d4dab62..b44093906 100644\n> > > --- a/include/libcamera/internal/camera_sensor_properties.h\n> > > +++ b/include/libcamera/internal/camera_sensor_properties.h\n> > > @@ -9,7 +9,7 @@\n> > >\n> > >  #include <map>\n> > >  #include <stdint.h>\n> > > -#include <string>\n> > > +#include <string_view>\n> > >\n> > >  #include <libcamera/control_ids.h>\n> > >  #include <libcamera/geometry.h>\n> > > @@ -24,7 +24,7 @@ struct CameraSensorProperties {\n> > >  \t\tuint8_t hblankDelay;\n> > >  \t};\n> > >\n> > > -\tstatic const CameraSensorProperties *get(const std::string &sensor);\n> > > +\tstatic const CameraSensorProperties *get(std::string_view sensor);\n> > >\n> > >  \tSize unitCellSize;\n> > >  \tstd::map<controls::draft::TestPatternModeEnum, int32_t> testPatternModes;\n> > > diff --git a/include/libcamera/internal/device_enumerator.h b/include/libcamera/internal/device_enumerator.h\n> > > index db3532a98..eecc39cfb 100644\n> > > --- a/include/libcamera/internal/device_enumerator.h\n> > > +++ b/include/libcamera/internal/device_enumerator.h\n> > > @@ -9,6 +9,7 @@\n> > >\n> > >  #include <memory>\n> > >  #include <string>\n> > > +#include <string_view>\n> > >  #include <vector>\n> > >\n> > >  #include <libcamera/base/signal.h>\n> > > @@ -48,7 +49,7 @@ public:\n> > >  protected:\n> > >  \tstd::unique_ptr<MediaDevice> createDevice(const std::string &deviceNode);\n> > >  \tvoid addDevice(std::unique_ptr<MediaDevice> media);\n> > > -\tvoid removeDevice(const std::string &deviceNode);\n> > > +\tvoid removeDevice(std::string_view deviceNode);\n> > >\n> > >  private:\n> > >  \tstd::vector<std::shared_ptr<MediaDevice>> devices_;\n> > > diff --git a/include/libcamera/internal/formats.h b/include/libcamera/internal/formats.h\n> > > index 6a3e9c16a..bd7ac6ed1 100644\n> > > --- a/include/libcamera/internal/formats.h\n> > > +++ b/include/libcamera/internal/formats.h\n> > > @@ -8,6 +8,7 @@\n> > >  #pragma once\n> > >\n> > >  #include <array>\n> > > +#include <string_view>\n> > >  #include <vector>\n> > >\n> > >  #include <libcamera/geometry.h>\n> > > @@ -35,7 +36,7 @@ public:\n> > >\n> > >  \tstatic const PixelFormatInfo &info(const PixelFormat &format);\n> > >  \tstatic const PixelFormatInfo &info(const V4L2PixelFormat &format);\n> > > -\tstatic const PixelFormatInfo &info(const std::string &name);\n> > > +\tstatic const PixelFormatInfo &info(std::string_view name);\n> > >\n> > >  \tunsigned int stride(unsigned int width, unsigned int plane,\n> > >  \t\t\t    unsigned int align = 1) const;\n> > > diff --git a/include/libcamera/internal/media_device.h b/include/libcamera/internal/media_device.h\n> > > index e412d3a0b..91610a7aa 100644\n> > > --- a/include/libcamera/internal/media_device.h\n> > > +++ b/include/libcamera/internal/media_device.h\n> > > @@ -9,6 +9,7 @@\n> > >\n> > >  #include <map>\n> > >  #include <string>\n> > > +#include <string_view>\n> > >  #include <vector>\n> > >\n> > >  #include <linux/media.h>\n> > > @@ -44,10 +45,10 @@ public:\n> > >  \tunsigned int hwRevision() const { return hwRevision_; }\n> > >\n> > >  \tconst std::vector<MediaEntity *> &entities() const { return entities_; }\n> > > -\tMediaEntity *getEntityByName(const std::string &name) const;\n> > > +\tMediaEntity *getEntityByName(std::string_view name) const;\n> > >\n> > > -\tMediaLink *link(const std::string &sourceName, unsigned int sourceIdx,\n> > > -\t\t\tconst std::string &sinkName, unsigned int sinkIdx);\n> > > +\tMediaLink *link(std::string_view sourceName, unsigned int sourceIdx,\n> > > +\t\t\tstd::string_view sinkName, unsigned int sinkIdx);\n> > >  \tMediaLink *link(const MediaEntity *source, unsigned int sourceIdx,\n> > >  \t\t\tconst MediaEntity *sink, unsigned int sinkIdx);\n> > >  \tMediaLink *link(const MediaPad *source, const MediaPad *sink);\n> > > diff --git a/include/libcamera/internal/pipeline_handler.h b/include/libcamera/internal/pipeline_handler.h\n> > > index fb28a18d0..45eafce9b 100644\n> > > --- a/include/libcamera/internal/pipeline_handler.h\n> > > +++ b/include/libcamera/internal/pipeline_handler.h\n> > > @@ -10,6 +10,7 @@\n> > >  #include <memory>\n> > >  #include <queue>\n> > >  #include <string>\n> > > +#include <string_view>\n> > >  #include <sys/types.h>\n> > >  #include <vector>\n> > >\n> > > @@ -112,7 +113,7 @@ public:\n> > >  \tconst std::string &name() const { return name_; }\n> > >\n> > >  \tstatic std::vector<PipelineHandlerFactoryBase *> &factories();\n> > > -\tstatic const PipelineHandlerFactoryBase *getFactoryByName(const std::string &name);\n> > > +\tstatic const PipelineHandlerFactoryBase *getFactoryByName(std::string_view name);\n> > >\n> > >  private:\n> > >  \tstatic void registerType(PipelineHandlerFactoryBase *factory);\n> > > diff --git a/include/libcamera/internal/v4l2_subdevice.h b/include/libcamera/internal/v4l2_subdevice.h\n> > > index 194382f84..d17365e14 100644\n> > > --- a/include/libcamera/internal/v4l2_subdevice.h\n> > > +++ b/include/libcamera/internal/v4l2_subdevice.h\n> > > @@ -11,6 +11,7 @@\n> > >  #include <optional>\n> > >  #include <ostream>\n> > >  #include <string>\n> > > +#include <string_view>\n> > >  #include <vector>\n> > >\n> > >  #include <linux/v4l2-subdev.h>\n> > > @@ -161,7 +162,7 @@ public:\n> > >  \tconst V4L2SubdeviceCapability &caps() const { return caps_; }\n> > >\n> > >  \tstatic std::unique_ptr<V4L2Subdevice>\n> > > -\tfromEntityName(const MediaDevice *media, const std::string &entity);\n> > > +\tfromEntityName(const MediaDevice *media, std::string_view entity);\n> > >\n> > >  protected:\n> > >  \tstd::string logPrefix() const override;\n> > > diff --git a/include/libcamera/internal/v4l2_videodevice.h b/include/libcamera/internal/v4l2_videodevice.h\n> > > index f021c2a01..c256e82af 100644\n> > > --- a/include/libcamera/internal/v4l2_videodevice.h\n> > > +++ b/include/libcamera/internal/v4l2_videodevice.h\n> > > @@ -14,6 +14,7 @@\n> > >  #include <ostream>\n> > >  #include <stdint.h>\n> > >  #include <string>\n> > > +#include <string_view>\n> > >  #include <unordered_set>\n> > >  #include <vector>\n> > >\n> > > @@ -228,7 +229,7 @@ public:\n> > >  \tSignal<> dequeueTimeout;\n> > >\n> > >  \tstatic std::unique_ptr<V4L2VideoDevice>\n> > > -\tfromEntityName(const MediaDevice *media, const std::string &entity);\n> > > +\tfromEntityName(const MediaDevice *media, std::string_view entity);\n> > >\n> > >  \tV4L2PixelFormat toV4L2PixelFormat(const PixelFormat &pixelFormat) const;\n> > >\n> > > diff --git a/include/libcamera/pixel_format.h b/include/libcamera/pixel_format.h\n> > > index 1b4d8c7c8..874b2528b 100644\n> > > --- a/include/libcamera/pixel_format.h\n> > > +++ b/include/libcamera/pixel_format.h\n> > > @@ -10,6 +10,7 @@\n> > >  #include <ostream>\n> > >  #include <stdint.h>\n> > >  #include <string>\n> > > +#include <string_view>\n> > >\n> > >  namespace libcamera {\n> > >\n> > > @@ -38,7 +39,7 @@ public:\n> > >\n> > >  \tstd::string toString() const;\n> > >\n> > > -\tstatic PixelFormat fromString(const std::string &name);\n> > > +\tstatic PixelFormat fromString(std::string_view name);\n> > >\n> > >  private:\n> > >  \tuint32_t fourcc_;\n> > > diff --git a/src/apps/cam/capture_script.cpp b/src/apps/cam/capture_script.cpp\n> > > index fc1dfa75f..d4760ea78 100644\n> > > --- a/src/apps/cam/capture_script.cpp\n> > > +++ b/src/apps/cam/capture_script.cpp\n> > > @@ -432,7 +432,7 @@ std::vector<std::string> CaptureScript::parseSingleArray()\n> > >  \t}\n> > >  }\n> > >\n> > > -void CaptureScript::unpackFailure(const ControlId *id, const std::string &repr)\n> > > +void CaptureScript::unpackFailure(const ControlId *id, std::string_view repr)\n> > >  {\n> > >  \tstatic const std::map<unsigned int, const char *> typeNames = {\n> > >  \t\t{ ControlTypeNone, \"none\" },\n> > > diff --git a/src/apps/cam/capture_script.h b/src/apps/cam/capture_script.h\n> > > index 294b92036..fb40371f2 100644\n> > > --- a/src/apps/cam/capture_script.h\n> > > +++ b/src/apps/cam/capture_script.h\n> > > @@ -10,6 +10,7 @@\n> > >  #include <map>\n> > >  #include <memory>\n> > >  #include <string>\n> > > +#include <string_view>\n> > >\n> > >  #include <libcamera/camera.h>\n> > >  #include <libcamera/controls.h>\n> > > @@ -67,7 +68,7 @@ private:\n> > >  \tstd::vector<std::string> parseSingleArray();\n> > >\n> > >  \tvoid unpackFailure(const libcamera::ControlId *id,\n> > > -\t\t\t   const std::string &repr);\n> > > +\t\t\t   std::string_view repr);\n> > >  \tlibcamera::ControlValue unpackControl(const libcamera::ControlId *id);\n> > >  \tlibcamera::Rectangle unpackRectangle(const std::vector<std::string> &strVec);\n> > >  };\n> > > diff --git a/src/apps/cam/drm.cpp b/src/apps/cam/drm.cpp\n> > > index 47bbb6b05..fd9c59ec4 100644\n> > > --- a/src/apps/cam/drm.cpp\n> > > +++ b/src/apps/cam/drm.cpp\n> > > @@ -57,7 +57,7 @@ Object::~Object()\n> > >  {\n> > >  }\n> > >\n> > > -const Property *Object::property(const std::string &name) const\n> > > +const Property *Object::property(std::string_view name) const\n> > >  {\n> > >  \tfor (const PropertyValue &pv : properties_) {\n> > >  \t\tconst Property *property = static_cast<const Property *>(dev_->object(pv.id()));\n> > > @@ -68,7 +68,7 @@ const Property *Object::property(const std::string &name) const\n> > >  \treturn nullptr;\n> > >  }\n> > >\n> > > -const PropertyValue *Object::propertyValue(const std::string &name) const\n> > > +const PropertyValue *Object::propertyValue(std::string_view name) const\n> > >  {\n> > >  \tfor (const PropertyValue &pv : properties_) {\n> > >  \t\tconst Property *property = static_cast<const Property *>(dev_->object(pv.id()));\n> > > @@ -320,7 +320,7 @@ AtomicRequest::~AtomicRequest()\n> > >  \t\tdrmModeAtomicFree(request_);\n> > >  }\n> > >\n> > > -int AtomicRequest::addProperty(const Object *object, const std::string &property,\n> > > +int AtomicRequest::addProperty(const Object *object, std::string_view property,\n> > >  \t\t\t       uint64_t value)\n> > >  {\n> > >  \tif (!valid_)\n> > > @@ -335,7 +335,7 @@ int AtomicRequest::addProperty(const Object *object, const std::string &property\n> > >  \treturn addProperty(object->id(), prop->id(), value);\n> > >  }\n> > >\n> > > -int AtomicRequest::addProperty(const Object *object, const std::string &property,\n> > > +int AtomicRequest::addProperty(const Object *object, std::string_view property,\n> > >  \t\t\t       std::unique_ptr<Blob> blob)\n> > >  {\n> > >  \tif (!valid_)\n> > > diff --git a/src/apps/cam/drm.h b/src/apps/cam/drm.h\n> > > index 1ba83b6eb..aa1b06400 100644\n> > > --- a/src/apps/cam/drm.h\n> > > +++ b/src/apps/cam/drm.h\n> > > @@ -13,6 +13,7 @@\n> > >  #include <memory>\n> > >  #include <stdint.h>\n> > >  #include <string>\n> > > +#include <string_view>\n> > >  #include <vector>\n> > >\n> > >  #include <libcamera/base/signal.h>\n> > > @@ -57,8 +58,8 @@ public:\n> > >  \tuint32_t id() const { return id_; }\n> > >  \tType type() const { return type_; }\n> > >\n> > > -\tconst Property *property(const std::string &name) const;\n> > > -\tconst PropertyValue *propertyValue(const std::string &name) const;\n> > > +\tconst Property *property(std::string_view name) const;\n> > > +\tconst PropertyValue *propertyValue(std::string_view name) const;\n> > >  \tconst std::vector<PropertyValue> &properties() const { return properties_; }\n> > >\n> > >  protected:\n> > > @@ -260,9 +261,9 @@ public:\n> > >  \tDevice *device() const { return dev_; }\n> > >  \tbool isValid() const { return valid_; }\n> > >\n> > > -\tint addProperty(const Object *object, const std::string &property,\n> > > +\tint addProperty(const Object *object, std::string_view property,\n> > >  \t\t\tuint64_t value);\n> > > -\tint addProperty(const Object *object, const std::string &property,\n> > > +\tint addProperty(const Object *object, std::string_view property,\n> > >  \t\t\tstd::unique_ptr<Blob> blob);\n> > >  \tint commit(unsigned int flags = 0);\n> > >\n> > > diff --git a/src/ipa/libipa/camera_sensor_helper.cpp b/src/ipa/libipa/camera_sensor_helper.cpp\n> > > index 7c66cd57d..4ed050b14 100644\n> > > --- a/src/ipa/libipa/camera_sensor_helper.cpp\n> > > +++ b/src/ipa/libipa/camera_sensor_helper.cpp\n> > > @@ -240,7 +240,7 @@ CameraSensorHelperFactoryBase::CameraSensorHelperFactoryBase(const std::string n\n> > >   * corresponding to the named factory or a null pointer if no such factory\n> > >   * exists\n> > >   */\n> > > -std::unique_ptr<CameraSensorHelper> CameraSensorHelperFactoryBase::create(const std::string &name)\n> > > +std::unique_ptr<CameraSensorHelper> CameraSensorHelperFactoryBase::create(std::string_view name)\n> > >  {\n> > >  \tconst std::vector<CameraSensorHelperFactoryBase *> &factories =\n> > >  \t\tCameraSensorHelperFactoryBase::factories();\n> > > diff --git a/src/ipa/libipa/camera_sensor_helper.h b/src/ipa/libipa/camera_sensor_helper.h\n> > > index a9300a64f..eedc80114 100644\n> > > --- a/src/ipa/libipa/camera_sensor_helper.h\n> > > +++ b/src/ipa/libipa/camera_sensor_helper.h\n> > > @@ -11,6 +11,7 @@\n> > >  #include <optional>\n> > >  #include <stdint.h>\n> > >  #include <string>\n> > > +#include <string_view>\n> > >  #include <variant>\n> > >  #include <vector>\n> > >\n> > > @@ -56,7 +57,7 @@ public:\n> > >  \tCameraSensorHelperFactoryBase(const std::string name);\n> > >  \tvirtual ~CameraSensorHelperFactoryBase() = default;\n> > >\n> > > -\tstatic std::unique_ptr<CameraSensorHelper> create(const std::string &name);\n> > > +\tstatic std::unique_ptr<CameraSensorHelper> create(std::string_view name);\n> > >\n> > >  \tstatic std::vector<CameraSensorHelperFactoryBase *> &factories();\n> > >\n> > > diff --git a/src/ipa/libipa/module.cpp b/src/ipa/libipa/module.cpp\n> > > index 64ca91419..91fb588e7 100644\n> > > --- a/src/ipa/libipa/module.cpp\n> > > +++ b/src/ipa/libipa/module.cpp\n> > > @@ -107,7 +107,7 @@ namespace ipa {\n> > >   */\n> > >\n> > >  /**\n> > > - * \\fn Module::createAlgorithm(const std::string &name)\n> > > + * \\fn Module::createAlgorithm(std::string_view name)\n> > >   * \\brief Create an instance of an Algorithm by name\n> > >   * \\param[in] name The algorithm name\n> > >   *\n> > > diff --git a/src/ipa/libipa/module.h b/src/ipa/libipa/module.h\n> > > index 0fb51916f..62c700a64 100644\n> > > --- a/src/ipa/libipa/module.h\n> > > +++ b/src/ipa/libipa/module.h\n> > > @@ -9,7 +9,7 @@\n> > >\n> > >  #include <list>\n> > >  #include <memory>\n> > > -#include <string>\n> > > +#include <string_view>\n> > >  #include <vector>\n> > >\n> > >  #include <libcamera/base/log.h>\n> > > @@ -95,7 +95,7 @@ private:\n> > >  \t\treturn 0;\n> > >  \t}\n> > >\n> > > -\tstatic std::unique_ptr<Algorithm<Module>> createAlgorithm(const std::string &name)\n> > > +\tstatic std::unique_ptr<Algorithm<Module>> createAlgorithm(std::string_view name)\n> > >  \t{\n> > >  \t\tfor (const AlgorithmFactoryBase<Module> *factory : factories()) {\n> > >  \t\t\tif (factory->name() == name)\n> > > diff --git a/src/libcamera/base/utils.cpp b/src/libcamera/base/utils.cpp\n> > > index bcfc1941a..de6e2afd6 100644\n> > > --- a/src/libcamera/base/utils.cpp\n> > > +++ b/src/libcamera/base/utils.cpp\n> > > @@ -80,7 +80,7 @@ char *secure_getenv(const char *name)\n> > >   *\n> > >   * \\return A string of the directory component of the path\n> > >   */\n> > > -std::string dirname(const std::string &path)\n> > > +std::string dirname(std::string_view path)\n> > >  {\n> > >  \tif (path.empty())\n> > >  \t\treturn \".\";\n> > > @@ -116,7 +116,7 @@ std::string dirname(const std::string &path)\n> > >  \t\tpos--;\n> > >  \t}\n> > >\n> > > -\treturn path.substr(0, pos + 1);\n> > > +\treturn std::string(path.substr(0, pos + 1));\n> > >  }\n> > >\n> > >  /**\n> > > @@ -278,7 +278,7 @@ std::string details::StringSplitter::iterator::operator*() const\n> > >\n> > >  /**\n> > >   * \\fn template<typename Container, typename UnaryOp> \\\n> > > - * std::string utils::join(const Container &items, const std::string &sep, UnaryOp op)\n> > > + * std::string utils::join(const Container &items, std::string_view sep, UnaryOp op)\n> > >   * \\brief Join elements of a container in a string with a separator\n> > >   * \\param[in] items The container\n> > >   * \\param[in] sep The separator to add between elements\n> > > @@ -319,7 +319,7 @@ details::StringSplitter split(const std::string &str, const std::string &delim)\n> > >   *\n> > >   * \\return A string equal to \\a str stripped out of all non-ASCII characters\n> > >   */\n> > > -std::string toAscii(const std::string &str)\n> > > +std::string toAscii(std::string_view str)\n> > >  {\n> > >  \tstd::string ret;\n> > >  \tfor (const char &c : str)\n> > > diff --git a/src/libcamera/camera_manager.cpp b/src/libcamera/camera_manager.cpp\n> > > index 87e6717ec..179fa37ea 100644\n> > > --- a/src/libcamera/camera_manager.cpp\n> > > +++ b/src/libcamera/camera_manager.cpp\n> > > @@ -382,7 +382,7 @@ std::vector<std::shared_ptr<Camera>> CameraManager::cameras() const\n> > >   *\n> > >   * \\return Shared pointer to Camera object or nullptr if camera not found\n> > >   */\n> > > -std::shared_ptr<Camera> CameraManager::get(const std::string &id)\n> > > +std::shared_ptr<Camera> CameraManager::get(std::string_view id)\n> > >  {\n> > >  \tPrivate *const d = _d();\n> > >\n> > > diff --git a/src/libcamera/device_enumerator.cpp b/src/libcamera/device_enumerator.cpp\n> > > index ae17862f6..8744a90f3 100644\n> > > --- a/src/libcamera/device_enumerator.cpp\n> > > +++ b/src/libcamera/device_enumerator.cpp\n> > > @@ -272,7 +272,7 @@ void DeviceEnumerator::addDevice(std::unique_ptr<MediaDevice> media)\n> > >   * enumerator with addDevice(). The media device's MediaDevice::disconnected\n> > >   * signal is emitted.\n> > >   */\n> > > -void DeviceEnumerator::removeDevice(const std::string &deviceNode)\n> > > +void DeviceEnumerator::removeDevice(std::string_view deviceNode)\n> > >  {\n> > >  \tstd::shared_ptr<MediaDevice> media;\n> > >\n> > > diff --git a/src/libcamera/device_enumerator_udev.cpp b/src/libcamera/device_enumerator_udev.cpp\n> > > index 4e20a3cc0..c330f30bc 100644\n> > > --- a/src/libcamera/device_enumerator_udev.cpp\n> > > +++ b/src/libcamera/device_enumerator_udev.cpp\n> > > @@ -351,7 +351,7 @@ void DeviceEnumeratorUdev::udevNotify()\n> > >  \t} else if (action == \"remove\") {\n> > >  \t\tconst char *subsystem = udev_device_get_subsystem(dev);\n> > >  \t\tif (subsystem && !strcmp(subsystem, \"media\"))\n> > > -\t\t\tremoveDevice(std::string(deviceNode));\n> > > +\t\t\tremoveDevice(deviceNode);\n> > >  \t}\n> > >\n> > >  \tudev_device_unref(dev);\n> > > diff --git a/src/libcamera/formats.cpp b/src/libcamera/formats.cpp\n> > > index bfcdfc089..112dfe66b 100644\n> > > --- a/src/libcamera/formats.cpp\n> > > +++ b/src/libcamera/formats.cpp\n> > > @@ -1037,7 +1037,7 @@ const PixelFormatInfo &PixelFormatInfo::info(const V4L2PixelFormat &format)\n> > >   * \\return The PixelFormatInfo describing the PixelFormat matching the\n> > >   * \\a name if known, or an invalid PixelFormatInfo otherwise\n> > >   */\n> > > -const PixelFormatInfo &PixelFormatInfo::info(const std::string &name)\n> > > +const PixelFormatInfo &PixelFormatInfo::info(std::string_view name)\n> > >  {\n> > >  \tfor (const auto &info : pixelFormatInfo) {\n> > >  \t\tif (info.second.name == name)\n> > > diff --git a/src/libcamera/media_device.cpp b/src/libcamera/media_device.cpp\n> > > index d71dad74d..131b34446 100644\n> > > --- a/src/libcamera/media_device.cpp\n> > > +++ b/src/libcamera/media_device.cpp\n> > > @@ -331,7 +331,7 @@ done:\n> > >   * \\param[in] name The entity name\n> > >   * \\return The entity with \\a name, or nullptr if no such entity is found\n> > >   */\n> > > -MediaEntity *MediaDevice::getEntityByName(const std::string &name) const\n> > > +MediaEntity *MediaDevice::getEntityByName(std::string_view name) const\n> > >  {\n> > >  \tfor (MediaEntity *e : entities_)\n> > >  \t\tif (e->name() == name)\n> > > @@ -359,8 +359,8 @@ MediaEntity *MediaDevice::getEntityByName(const std::string &name) const\n> > >   * \\return The link that connects the two pads, or nullptr if no such a link\n> > >   * exists\n> > >   */\n> > > -MediaLink *MediaDevice::link(const std::string &sourceName, unsigned int sourceIdx,\n> > > -\t\t\t     const std::string &sinkName, unsigned int sinkIdx)\n> > > +MediaLink *MediaDevice::link(std::string_view sourceName, unsigned int sourceIdx,\n> > > +\t\t\t     std::string_view sinkName, unsigned int sinkIdx)\n> > >  {\n> > >  \tconst MediaEntity *source = getEntityByName(sourceName);\n> > >  \tconst MediaEntity *sink = getEntityByName(sinkName);\n> > > @@ -382,8 +382,8 @@ MediaLink *MediaDevice::link(const std::string &sourceName, unsigned int sourceI\n> > >   * entity \\a source, to the pad at index \\a sinkIdx of the sink entity \\a\n> > >   * sink, if any.\n> > >   *\n> > > - * \\sa link(const std::string &sourceName, unsigned int sourceIdx,\n> > > - *          const std::string &sinkName, unsigned int sinkIdx)\n> > > + * \\sa link(std::string_view sourceName, unsigned int sourceIdx,\n> > > + *          std::string_view sinkName, unsigned int sinkIdx)\n> > >   * \\sa link(const MediaPad *source, const MediaPad *sink)\n> > >   *\n> > >   * \\return The link that connects the two pads, or nullptr if no such a link\n> > > @@ -406,8 +406,8 @@ MediaLink *MediaDevice::link(const MediaEntity *source, unsigned int sourceIdx,\n> > >   * \\param[in] source The source pad\n> > >   * \\param[in] sink The sink pad\n> > >   *\n> > > - * \\sa link(const std::string &sourceName, unsigned int sourceIdx,\n> > > - *          const std::string &sinkName, unsigned int sinkIdx)\n> > > + * \\sa link(std::string_view sourceName, unsigned int sourceIdx,\n> > > + *          std::string_view sinkName, unsigned int sinkIdx)\n> > >   * \\sa link(const MediaEntity *source, unsigned int sourceIdx,\n> > >   *          const MediaEntity *sink, unsigned int sinkIdx)\n> > >   *\n> > > diff --git a/src/libcamera/pipeline_handler.cpp b/src/libcamera/pipeline_handler.cpp\n> > > index caa5c20e7..6b395c666 100644\n> > > --- a/src/libcamera/pipeline_handler.cpp\n> > > +++ b/src/libcamera/pipeline_handler.cpp\n> > > @@ -852,7 +852,7 @@ std::vector<PipelineHandlerFactoryBase *> &PipelineHandlerFactoryBase::factories\n> > >   * \\param[in] name The pipeline handler name\n> > >   * \\return The factory of the pipeline with name \\a name, or nullptr if not found\n> > >   */\n> > > -const PipelineHandlerFactoryBase *PipelineHandlerFactoryBase::getFactoryByName(const std::string &name)\n> > > +const PipelineHandlerFactoryBase *PipelineHandlerFactoryBase::getFactoryByName(std::string_view name)\n> > >  {\n> > >  \tconst std::vector<PipelineHandlerFactoryBase *> &factories =\n> > >  \t\tPipelineHandlerFactoryBase::factories();\n> > > diff --git a/src/libcamera/pixel_format.cpp b/src/libcamera/pixel_format.cpp\n> > > index 314179a81..22f1520fd 100644\n> > > --- a/src/libcamera/pixel_format.cpp\n> > > +++ b/src/libcamera/pixel_format.cpp\n> > > @@ -135,7 +135,7 @@ std::string PixelFormat::toString() const\n> > >   * \\return The PixelFormat represented by the \\a name if known, or an\n> > >   * invalid pixel format otherwise.\n> > >   */\n> > > -PixelFormat PixelFormat::fromString(const std::string &name)\n> > > +PixelFormat PixelFormat::fromString(std::string_view name)\n> > >  {\n> > >  \treturn PixelFormatInfo::info(name).format;\n> > >  }\n> > > diff --git a/src/libcamera/sensor/camera_sensor_properties.cpp b/src/libcamera/sensor/camera_sensor_properties.cpp\n> > > index 2b06c5a1a..4283cacfa 100644\n> > > --- a/src/libcamera/sensor/camera_sensor_properties.cpp\n> > > +++ b/src/libcamera/sensor/camera_sensor_properties.cpp\n> > > @@ -78,9 +78,9 @@ LOG_DEFINE_CATEGORY(CameraSensorProperties)\n> > >   * \\return A pointer to the CameraSensorProperties instance associated with a sensor\n> > >   * or nullptr if the sensor is not supported\n> > >   */\n> > > -const CameraSensorProperties *CameraSensorProperties::get(const std::string &sensor)\n> > > +const CameraSensorProperties *CameraSensorProperties::get(std::string_view sensor)\n> > >  {\n> > > -\tstatic const std::map<std::string, const CameraSensorProperties> sensorProps = {\n> > > +\tstatic const std::map<std::string_view, const CameraSensorProperties> sensorProps = {\n> > >  \t\t{ \"ar0144\", {\n> > >  \t\t\t.unitCellSize = { 3000, 3000 },\n> > >  \t\t\t.testPatternModes = {\n> > > diff --git a/src/libcamera/v4l2_subdevice.cpp b/src/libcamera/v4l2_subdevice.cpp\n> > > index 3a0d075f9..7e85b33be 100644\n> > > --- a/src/libcamera/v4l2_subdevice.cpp\n> > > +++ b/src/libcamera/v4l2_subdevice.cpp\n> > > @@ -1688,7 +1688,7 @@ const std::string &V4L2Subdevice::model()\n> > >   */\n> > >  std::unique_ptr<V4L2Subdevice>\n> > >  V4L2Subdevice::fromEntityName(const MediaDevice *media,\n> > > -\t\t\t      const std::string &entity)\n> > > +\t\t\t      std::string_view entity)\n> > >  {\n> > >  \tMediaEntity *mediaEntity = media->getEntityByName(entity);\n> > >  \tif (!mediaEntity)\n> > > diff --git a/src/libcamera/v4l2_videodevice.cpp b/src/libcamera/v4l2_videodevice.cpp\n> > > index a5cf67845..834a1bd0d 100644\n> > > --- a/src/libcamera/v4l2_videodevice.cpp\n> > > +++ b/src/libcamera/v4l2_videodevice.cpp\n> > > @@ -2077,7 +2077,7 @@ void V4L2VideoDevice::watchdogExpired()\n> > >   */\n> > >  std::unique_ptr<V4L2VideoDevice>\n> > >  V4L2VideoDevice::fromEntityName(const MediaDevice *media,\n> > > -\t\t\t\tconst std::string &entity)\n> > > +\t\t\t\tstd::string_view entity)\n> > >  {\n> > >  \tMediaEntity *mediaEntity = media->getEntityByName(entity);\n> > >  \tif (!mediaEntity)\n> > > diff --git a/src/py/libcamera/py_camera_manager.h b/src/py/libcamera/py_camera_manager.h\n> > > index 3574db236..af69b915e 100644\n> > > --- a/src/py/libcamera/py_camera_manager.h\n> > > +++ b/src/py/libcamera/py_camera_manager.h\n> > > @@ -20,7 +20,7 @@ public:\n> > >  \t~PyCameraManager();\n> > >\n> > >  \tpybind11::list cameras();\n> > > -\tstd::shared_ptr<Camera> get(const std::string &name) { return cameraManager_->get(name); }\n> > > +\tstd::shared_ptr<Camera> get(std::string_view name) { return cameraManager_->get(name); }\n> > >\n> > >  \tstatic const std::string &version() { return CameraManager::version(); }\n> > >\n> > > diff --git a/src/py/libcamera/py_main.cpp b/src/py/libcamera/py_main.cpp\n> > > index 441a70ab4..820768c24 100644\n> > > --- a/src/py/libcamera/py_main.cpp\n> > > +++ b/src/py/libcamera/py_main.cpp\n> > > @@ -510,7 +510,7 @@ PYBIND11_MODULE(_libcamera, m)\n> > >  \tpyPixelFormat\n> > >  \t\t.def(py::init<>())\n> > >  \t\t.def(py::init<uint32_t, uint64_t>())\n> > > -\t\t.def(py::init<>([](const std::string &str) {\n> > > +\t\t.def(py::init<>([](std::string_view str) {\n> > >  \t\t\treturn PixelFormat::fromString(str);\n> > >  \t\t}))\n> > >  \t\t.def_property_readonly(\"fourcc\", &PixelFormat::fourcc)","headers":{"Return-Path":"<libcamera-devel-bounces@lists.libcamera.org>","X-Original-To":"parsemail@patchwork.libcamera.org","Delivered-To":"parsemail@patchwork.libcamera.org","Received":["from lancelot.ideasonboard.com (lancelot.ideasonboard.com\n\t[92.243.16.209])\n\tby patchwork.libcamera.org (Postfix) with ESMTPS id 47AA5C32F5\n\tfor <parsemail@patchwork.libcamera.org>;\n\tSun, 15 Dec 2024 23:15:07 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 7F1CA67F2E;\n\tMon, 16 Dec 2024 00:15:06 +0100 (CET)","from perceval.ideasonboard.com (perceval.ideasonboard.com\n\t[213.167.242.64])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 553B86189B\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tMon, 16 Dec 2024 00:15:04 +0100 (CET)","from pendragon.ideasonboard.com (81-175-209-231.bb.dnainternet.fi\n\t[81.175.209.231])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id E178F2C6;\n\tMon, 16 Dec 2024 00:14:27 +0100 (CET)"],"Authentication-Results":"lancelot.ideasonboard.com; dkim=pass (1024-bit key;\n\tunprotected) header.d=ideasonboard.com header.i=@ideasonboard.com\n\theader.b=\"KDX9LdNx\"; dkim-atps=neutral","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1734304468;\n\tbh=GzpZrAqyF0UuqafcB22kAWEblPlFGlqa8adyZUoha5U=;\n\th=Date:From:To:Cc:Subject:References:In-Reply-To:From;\n\tb=KDX9LdNxl9UD8vkB7jVkyJ9r2s4F85XctWFgczSjtD3SSlaZSj1uDU6J+9KO8iSbL\n\tcr4mMN/YYvOO0reDSYeAm9B4BQqTtNuZk9hSIZe+GXQLqfG6TLe/J01PHhen5GE+xa\n\t3iJOSdrULSIsIyQjmCqJFcisxRhtI2MA1ICUXI1k=","Date":"Mon, 16 Dec 2024 01:14:47 +0200","From":"Laurent Pinchart <laurent.pinchart@ideasonboard.com>","To":"=?utf-8?q?Barnab=C3=A1s_P=C5=91cze?= <pobrn@protonmail.com>","Cc":"libcamera-devel@lists.libcamera.org","Subject":"Re: [RFC PATCH v1] treewide: Prefer `std::string_view` over `const\n\tstd::string&` in parameters","Message-ID":"<20241215231447.GB31078@pendragon.ideasonboard.com>","References":"<20241215204802.850593-1-pobrn@protonmail.com>\n\t<20241215205643.GQ9975@pendragon.ideasonboard.com>\n\t<ZhYd-vdQuuQt3zHES9ZrjP_B7Hg-a4_I1GF91qrXD6bvrqDdknz8eZD5dyBt5fIlLd-QrybBSaiGaG-ISVwnuxXkX4oilIm2gCPZ19mYbBY=@protonmail.com>","MIME-Version":"1.0","Content-Type":"text/plain; charset=utf-8","Content-Disposition":"inline","Content-Transfer-Encoding":"8bit","In-Reply-To":"<ZhYd-vdQuuQt3zHES9ZrjP_B7Hg-a4_I1GF91qrXD6bvrqDdknz8eZD5dyBt5fIlLd-QrybBSaiGaG-ISVwnuxXkX4oilIm2gCPZ19mYbBY=@protonmail.com>","X-BeenThere":"libcamera-devel@lists.libcamera.org","X-Mailman-Version":"2.1.29","Precedence":"list","List-Id":"<libcamera-devel.lists.libcamera.org>","List-Unsubscribe":"<https://lists.libcamera.org/options/libcamera-devel>,\n\t<mailto:libcamera-devel-request@lists.libcamera.org?subject=unsubscribe>","List-Archive":"<https://lists.libcamera.org/pipermail/libcamera-devel/>","List-Post":"<mailto:libcamera-devel@lists.libcamera.org>","List-Help":"<mailto:libcamera-devel-request@lists.libcamera.org?subject=help>","List-Subscribe":"<https://lists.libcamera.org/listinfo/libcamera-devel>,\n\t<mailto:libcamera-devel-request@lists.libcamera.org?subject=subscribe>","Errors-To":"libcamera-devel-bounces@lists.libcamera.org","Sender":"\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>"}}]