From ddef786eeeee4b6cbc472da4878d8c1f73f69d69 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Barnab=C3=A1s=20P=C5=91cze?= Date: Sun, 4 Aug 2024 01:19:38 +0200 Subject: [PATCH] libcamera: v4l2_subdevice: Avoid reconstructing the `std::regex` object MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Make the `std::regex` object have static lifetime to avoid reconstructing it on every call. Signed-off-by: Barnabás Pőcze Reviewed-by: Kieran Bingham Reviewed-by: Isaac Scott --- src/libcamera/v4l2_subdevice.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/libcamera/v4l2_subdevice.cpp b/src/libcamera/v4l2_subdevice.cpp index 00205bc7..5e337a8c 100644 --- a/src/libcamera/v4l2_subdevice.cpp +++ b/src/libcamera/v4l2_subdevice.cpp @@ -1725,7 +1725,7 @@ const std::string &V4L2Subdevice::model() * an I2C address, and use the full entity name otherwise. */ std::string entityName = entity_->name(); - std::regex i2cRegex{ " [0-9]+-[0-9a-f]{4}" }; + static const std::regex i2cRegex{ " [0-9]+-[0-9a-f]{4}" }; std::smatch match; if (std::regex_search(entityName, match, i2cRegex))