From patchwork Tue Apr 18 16:03:03 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Barnab=C3=A1s_P=C5=91cze?= X-Patchwork-Id: 18537 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 4D83BBE173 for ; Tue, 18 Apr 2023 16:03:26 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 7F969627B1; Tue, 18 Apr 2023 18:03:25 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org; s=mail; t=1681833805; bh=KWmjLaINvHtPTQwwlEQLGSJ5Lj+077dmhvQkokyygWg=; h=Date:To:Subject:List-Id:List-Unsubscribe:List-Archive:List-Post: List-Help:List-Subscribe:From:Reply-To:From; b=Y+utlTpu/pZT02menYswaTl4xnyMpCWwYiKaoeZribGeuiYD61pskC9pX2ffrW7CJ LcOL2ZfriQzIxr5OQ05q9o6PMcFjOSx8hXhdqR5pUVOmIRYfrPlaks5wtTgmGXSQsg LSi07PGYu0O4QIS2+gOU8050xaFOqEra02azbik8Uvm71GBOrM/5+iyiezst4DFWD3 6J0yrJFdzas8FQWxrk8ERLBIMUevn+6wNw160Zn/xN4CxpCoFSKE8EpgO006G6p6Xg otNNdBevXRZUB0/A4SxMGipsYq9MRiqvJYtX1pEGp2nYeOB1Nl6B3e9Ed58ZlQd/5Y pPrBAetuDyGow== Received: from mail-40131.protonmail.ch (mail-40131.protonmail.ch [185.70.40.131]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 7C858603A2 for ; Tue, 18 Apr 2023 18:03:23 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (2048-bit key; unprotected) header.d=protonmail.com header.i=@protonmail.com header.b="Afb8Nx7G"; dkim-atps=neutral Date: Tue, 18 Apr 2023 16:03:03 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=protonmail.com; s=protonmail3; t=1681833793; x=1682092993; bh=KWmjLaINvHtPTQwwlEQLGSJ5Lj+077dmhvQkokyygWg=; h=Date:To:From:Subject:Message-ID:Feedback-ID:From:To:Cc:Date: Subject:Reply-To:Feedback-ID:Message-ID:BIMI-Selector; b=Afb8Nx7GmcyTN1hmad819Ygh9gr0f/6N3JjhN+B78Fqtkq2uFgSnKJ53v8SQEOTr0 QaIQirm5J67yGT34Iv1UPnNmVmhLAOqhdYkCeRK8A3NmhFNctfYJeN40tWS7wsPW/I +fKX9kdg3h9NpzKhnZAf8SuyR1ouwh0z9dfyEeZxi/AqcocWP1yfYWLUrHraRsk4II 14RMxT7JOfLj8ASGwEAouUXh6Wt0Vt3eKRzmgtPaGQFUEoHopc3lE6NhSJ+C5QOtl+ 9aC5U9asjYJW0RYdfxiysHjI9BshYaaF9fFlQX+JBUTkolUeS5drtvuuoyv5RRhWAq sstIoeARgOCAg== To: libcamera-devel@lists.libcamera.org Message-ID: <20230418160301.445828-1-pobrn@protonmail.com> Feedback-ID: 20568564:user:proton MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH] libcamera: device_enumerator_udev: Use std::string_view 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: , X-Patchwork-Original-From: =?utf-8?q?Barnab=C3=A1s_P=C5=91cze_via_libcamera-devel?= From: =?utf-8?q?Barnab=C3=A1s_P=C5=91cze?= Reply-To: =?utf-8?q?Barnab=C3=A1s_P=C5=91cze?= Errors-To: libcamera-devel-bounces@lists.libcamera.org Sender: "libcamera-devel" In `udevNotify()`, use `std::string_view` and defer the necessary `std::string` construction to the last possible point. Signed-off-by: Barnabás Pőcze --- src/libcamera/device_enumerator_udev.cpp | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) -- 2.40.0 diff --git a/src/libcamera/device_enumerator_udev.cpp b/src/libcamera/device_enumerator_udev.cpp index a63cd360..0abc1248 100644 --- a/src/libcamera/device_enumerator_udev.cpp +++ b/src/libcamera/device_enumerator_udev.cpp @@ -13,6 +13,7 @@ #include #include #include +#include #include #include #include @@ -331,18 +332,18 @@ int DeviceEnumeratorUdev::addV4L2Device(dev_t devnum) void DeviceEnumeratorUdev::udevNotify() { struct udev_device *dev = udev_monitor_receive_device(monitor_); - std::string action(udev_device_get_action(dev)); - std::string deviceNode(udev_device_get_devnode(dev)); + std::string_view action(udev_device_get_action(dev)); + std::string_view deviceNode(udev_device_get_devnode(dev)); LOG(DeviceEnumerator, Debug) - << action << " device " << udev_device_get_devnode(dev); + << action << " device " << deviceNode; if (action == "add") { addUdevDevice(dev); } else if (action == "remove") { const char *subsystem = udev_device_get_subsystem(dev); if (subsystem && !strcmp(subsystem, "media")) - removeDevice(deviceNode); + removeDevice(std::string(deviceNode)); } udev_device_unref(dev);