From patchwork Sun Dec 15 23:01:58 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Laurent Pinchart X-Patchwork-Id: 22320 Return-Path: X-Original-To: parsemail@patchwork.libcamera.org Delivered-To: parsemail@patchwork.libcamera.org Received: from lancelot.ideasonboard.com (lancelot.ideasonboard.com [92.243.16.209]) by patchwork.libcamera.org (Postfix) with ESMTPS id 43B7BC32F6 for ; Sun, 15 Dec 2024 23:02:26 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 2665A67F2E; Mon, 16 Dec 2024 00:02:25 +0100 (CET) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (1024-bit key; unprotected) header.d=ideasonboard.com header.i=@ideasonboard.com header.b="Rl8YL4pM"; dkim-atps=neutral Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [213.167.242.64]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id D31046189B for ; Mon, 16 Dec 2024 00:02:22 +0100 (CET) Received: from pendragon.ideasonboard.com (81-175-209-231.bb.dnainternet.fi [81.175.209.231]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id 82AD82C6; Mon, 16 Dec 2024 00:01:46 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1734303706; bh=ODz9WjcR17DqjYg2O1lgmx31zzjFxQ7GJnTw69xhXxo=; h=From:To:Cc:Subject:Date:From; b=Rl8YL4pM6pD3oIjPncM/DCpAO+mTIox+jpDzp0ZPVhbQ3Y7YykFW/gXH04478BV9v xhod65taG7T/IKyRX68xxfaC61INO4DpnPXuoB73/VKiPelgCMJ1MyNeSQofX9aCMs oXo7Dzw+eWs5z59Uol1/+kMzj+ENm5GeIpascS3Y= From: Laurent Pinchart To: libcamera-devel@lists.libcamera.org Cc: =?utf-8?q?Barnab=C3=A1s_P=C5=91cze?= Subject: [RFC PATCH 0/8] libcamera: Use std::string_view Date: Mon, 16 Dec 2024 01:01:58 +0200 Message-ID: <20241215230206.11002-1-laurent.pinchart@ideasonboard.com> X-Mailer: git-send-email 2.45.2 MIME-Version: 1.0 X-BeenThere: libcamera-devel@lists.libcamera.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: libcamera-devel-bounces@lists.libcamera.org Sender: "libcamera-devel" Hello, This patch series contains a bunch of changes I've had in my tree for some time. As a similar change was recently proposed ("[RFC PATCH v1] treewide: Prefer `std::string_view` over `const std::string&` in parameters"), I decided to clean my branch and post it as a base for discussions. After investigating string usage in C++ for a while, I'm convinced about the fact that it's a mess more than the value of std::string_view. The class isn't entirely bad, but it suffers from some limitations that make it painful to use until C++26. I tried to document usage guidelines in the coding style document (1/8) and found that rules were not easy to express. Some of the limitations can be worked around, as shown by patch 2/8. Patches 3/8 to 8/8 then start exploring more efficient string handling through the libcamera code base, with some changes that look quite fine, and some that are more problematic. My main issue with the string usage guidelines is perhaps that the best class to use depends on the internal implementation of a function, which is clearly problematic when designing stable APIs. I'll let everybody read the series and share their opinion. Laurent Pinchart (8): Documentation: coding-style: Document usage of classes for strings libcamera: base: utils: Add string_view concatenation operators libcamera: base: file: Fix string usage in class API libcamera: base: log: Use std::string_view libcamera: base: utils: Use std::string_view libcamera: Update string usage in internal APIs [DNI] libcamera: Use std::string_view in controls [DNI] libcamera: yaml_parser: Replace std::string reference with std::string_view Documentation/coding-style.rst | 98 +++++++++++++++++++ include/libcamera/base/file.h | 6 +- include/libcamera/base/log.h | 3 +- include/libcamera/base/utils.h | 62 ++++++++++-- include/libcamera/control_ids.h.in | 3 +- include/libcamera/controls.h | 21 ++-- .../internal/camera_sensor_properties.h | 4 +- include/libcamera/internal/converter.h | 3 +- .../internal/converter/converter_v4l2_m2m.h | 3 +- .../libcamera/internal/device_enumerator.h | 8 +- include/libcamera/internal/formats.h | 3 +- include/libcamera/internal/ipa_module.h | 3 +- include/libcamera/internal/ipa_proxy.h | 7 +- include/libcamera/internal/media_device.h | 9 +- include/libcamera/internal/pipeline_handler.h | 7 +- .../internal/software_isp/software_isp.h | 4 +- include/libcamera/internal/sysfs.h | 3 +- include/libcamera/internal/v4l2_device.h | 3 +- include/libcamera/internal/v4l2_subdevice.h | 3 +- include/libcamera/internal/v4l2_videodevice.h | 7 +- include/libcamera/internal/yaml_parser.h | 2 +- src/apps/cam/capture_script.h | 3 +- src/gstreamer/gstlibcamera-controls.cpp.in | 21 ++-- src/libcamera/base/file.cpp | 14 +-- src/libcamera/base/log.cpp | 31 +++--- src/libcamera/base/meson.build | 12 +++ src/libcamera/base/utils.cpp | 14 +-- src/libcamera/control_ids.cpp.in | 4 +- src/libcamera/controls.cpp | 15 ++- src/libcamera/device_enumerator.cpp | 10 +- src/libcamera/formats.cpp | 2 +- src/libcamera/ipa_module.cpp | 2 +- src/libcamera/ipa_proxy.cpp | 8 +- src/libcamera/media_device.cpp | 16 +-- src/libcamera/pipeline/uvcvideo/uvcvideo.cpp | 3 +- src/libcamera/pipeline_handler.cpp | 6 +- .../sensor/camera_sensor_properties.cpp | 4 +- src/libcamera/software_isp/software_isp.cpp | 3 +- src/libcamera/sysfs.cpp | 10 +- src/libcamera/v4l2_device.cpp | 2 +- src/libcamera/v4l2_subdevice.cpp | 3 +- src/libcamera/v4l2_videodevice.cpp | 7 +- src/libcamera/yaml_parser.cpp | 2 +- test/camera/camera_reconfigure.cpp | 2 +- test/hotplug-cameras.cpp | 3 +- test/utils.cpp | 34 +++++++ 46 files changed, 352 insertions(+), 141 deletions(-) base-commit: 8e15010b7dfa9c2a68dd57f924b5603784be0e09