libcamera: v4l2_subdevice: Avoid reconstructing the std::regex object

Make the `std::regex` object have static lifetime to avoid
reconstructing it on every call.

Signed-off-by: Barnabás Pőcze <barnabas.pocze@ideasonboard.com>
Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
Reviewed-by: Isaac Scott <isaac.scott@ideasonboard.com>
This commit is contained in:
Barnabás Pőcze
2024-08-04 01:19:38 +02:00
parent 330c390e6f
commit ddef786eee

View File

@@ -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))