mirror of
https://git.libcamera.org/libcamera/libcamera.git
synced 2025-07-12 23:09:45 +03:00
treewide: Avoid some copies in range-based for loops
Most of these have been found by the `performance-for-range-copy` check of `clang-tidy`. Signed-off-by: Barnabás Pőcze <pobrn@protonmail.com> Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
This commit is contained in:
parent
4e557e544b
commit
493f198e94
5 changed files with 8 additions and 14 deletions
|
@ -388,7 +388,7 @@ std::shared_ptr<Camera> CameraManager::get(const std::string &id)
|
|||
|
||||
MutexLocker locker(d->mutex_);
|
||||
|
||||
for (std::shared_ptr<Camera> camera : d->cameras_) {
|
||||
for (const std::shared_ptr<Camera> &camera : d->cameras_) {
|
||||
if (camera->id() == id)
|
||||
return camera;
|
||||
}
|
||||
|
|
|
@ -325,8 +325,9 @@ std::vector<std::string> ConverterFactoryBase::names()
|
|||
|
||||
for (ConverterFactoryBase *factory : factories) {
|
||||
list.push_back(factory->name_);
|
||||
for (auto alias : factory->compatibles())
|
||||
list.push_back(alias);
|
||||
|
||||
const auto &compatibles = factory->compatibles();
|
||||
list.insert(list.end(), compatibles.begin(), compatibles.end());
|
||||
}
|
||||
|
||||
return list;
|
||||
|
|
|
@ -39,7 +39,7 @@ ImageFrameGenerator::create(ImageFrames &imageFrames)
|
|||
* For each file in the directory, load the image,
|
||||
* convert it to NV12, and store the pointer.
|
||||
*/
|
||||
for (std::filesystem::path path : imageFrames.files) {
|
||||
for (const auto &path : imageFrames.files) {
|
||||
File file(path);
|
||||
if (!file.open(File::OpenModeFlag::ReadOnly)) {
|
||||
LOG(Virtual, Error) << "Failed to open image file " << file.fileName()
|
||||
|
|
|
@ -74,7 +74,7 @@ PipelineHandler::PipelineHandler(CameraManager *manager)
|
|||
|
||||
PipelineHandler::~PipelineHandler()
|
||||
{
|
||||
for (std::shared_ptr<MediaDevice> media : mediaDevices_)
|
||||
for (std::shared_ptr<MediaDevice> &media : mediaDevices_)
|
||||
media->release();
|
||||
}
|
||||
|
||||
|
|
|
@ -52,19 +52,12 @@ protected:
|
|||
for (l = devices; l != NULL; l = g_list_next(l)) {
|
||||
GstDevice *device = GST_DEVICE(l->data);
|
||||
g_autofree gchar *gst_name;
|
||||
bool matched = false;
|
||||
|
||||
g_autoptr(GstElement) element = gst_device_create_element(device, NULL);
|
||||
g_object_get(element, "camera-name", &gst_name, NULL);
|
||||
|
||||
for (auto name : cameraNames) {
|
||||
if (strcmp(name.c_str(), gst_name) == 0) {
|
||||
matched = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (!matched)
|
||||
if (std::find(cameraNames.begin(), cameraNames.end(), gst_name) ==
|
||||
cameraNames.end())
|
||||
return TestFail;
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue