@@ -110,13 +110,13 @@ std::string join(const Container &items, const std::string &sep, UnaryOp op)
std::ostringstream ss;
bool first = true;
- for (auto it = std::begin(items); it != std::end(items); ++it) {
+ for (const auto &item : items) {
if (!first)
ss << sep;
else
first = false;
- ss << op(*it);
+ ss << op(item);
}
return ss.str();
@@ -128,13 +128,13 @@ std::string join(const Container &items, const std::string &sep)
std::ostringstream ss;
bool first = true;
- for (auto it = std::begin(items); it != std::end(items); ++it) {
+ for (const auto &item : items) {
if (!first)
ss << sep;
else
first = false;
- ss << *it;
+ ss << item;
}
return ss.str();
@@ -749,10 +749,9 @@ int gst_libcamera_set_structure_field(GstStructure *structure, const ControlId *
switch (value.type()) {
case ControlTypeBool:
if (is_array) {
- Span<const bool> data = value.get<Span<const bool>>();
- for (auto it = data.begin(); it != data.end(); ++it) {
+ for (const auto &item : value.get<Span<const bool>>()) {
g_value_init(&x, type);
- g_value_set_boolean(&x, *it);
+ g_value_set_boolean(&x, item);
gst_value_array_append_and_take_value(&v, &x);
}
} else {
@@ -762,10 +761,9 @@ int gst_libcamera_set_structure_field(GstStructure *structure, const ControlId *
break;
case ControlTypeByte:
if (is_array) {
- Span<const uint8_t> data = value.get<Span<const uint8_t>>();
- for (auto it = data.begin(); it != data.end(); ++it) {
+ for (const auto &item : value.get<Span<const uint8_t>>()) {
g_value_init(&x, type);
- g_value_set_uint(&x, *it);
+ g_value_set_uint(&x, item);
gst_value_array_append_and_take_value(&v, &x);
}
} else {
@@ -775,10 +773,9 @@ int gst_libcamera_set_structure_field(GstStructure *structure, const ControlId *
break;
case ControlTypeUnsigned16:
if (is_array) {
- Span<const uint16_t> data = value.get<Span<const uint16_t>>();
- for (auto it = data.begin(); it != data.end(); ++it) {
+ for (const auto &item : value.get<Span<const uint16_t>>()) {
g_value_init(&x, type);
- g_value_set_uint(&x, *it);
+ g_value_set_uint(&x, item);
gst_value_array_append_and_take_value(&v, &x);
}
} else {
@@ -788,10 +785,9 @@ int gst_libcamera_set_structure_field(GstStructure *structure, const ControlId *
break;
case ControlTypeUnsigned32:
if (is_array) {
- Span<const uint32_t> data = value.get<Span<const uint32_t>>();
- for (auto it = data.begin(); it != data.end(); ++it) {
+ for (const auto &item : value.get<Span<const uint32_t>>()) {
g_value_init(&x, type);
- g_value_set_uint(&x, *it);
+ g_value_set_uint(&x, item);
gst_value_array_append_and_take_value(&v, &x);
}
} else {
@@ -801,10 +797,9 @@ int gst_libcamera_set_structure_field(GstStructure *structure, const ControlId *
break;
case ControlTypeInteger32:
if (is_array) {
- Span<const int32_t> data = value.get<Span<const int32_t>>();
- for (auto it = data.begin(); it != data.end(); ++it) {
+ for (const auto &item : value.get<Span<const int32_t>>()) {
g_value_init(&x, type);
- g_value_set_int(&x, *it);
+ g_value_set_int(&x, item);
gst_value_array_append_and_take_value(&v, &x);
}
} else {
@@ -827,10 +822,9 @@ int gst_libcamera_set_structure_field(GstStructure *structure, const ControlId *
break;
case ControlTypeInteger64:
if (is_array) {
- Span<const int64_t> data = value.get<Span<const int64_t>>();
- for (auto it = data.begin(); it != data.end(); ++it) {
+ for (const auto &item : value.get<Span<const int64_t>>()) {
g_value_init(&x, type);
- g_value_set_int64(&x, *it);
+ g_value_set_int64(&x, item);
gst_value_array_append_and_take_value(&v, &x);
}
} else {
@@ -840,10 +834,9 @@ int gst_libcamera_set_structure_field(GstStructure *structure, const ControlId *
break;
case ControlTypeFloat:
if (is_array) {
- Span<const float> data = value.get<Span<const float>>();
- for (auto it = data.begin(); it != data.end(); ++it) {
+ for (const auto &item : value.get<Span<const float>>()) {
g_value_init(&x, type);
- g_value_set_float(&x, *it);
+ g_value_set_float(&x, item);
gst_value_array_append_and_take_value(&v, &x);
}
} else {
@@ -862,27 +855,24 @@ int gst_libcamera_set_structure_field(GstStructure *structure, const ControlId *
break;
case ControlTypeSize:
if (is_array) {
- Span<const Size> data = value.get<Span<const Size>>();
- for (auto it = data.begin(); it != data.end(); ++it)
- gst_libcamera_gvalue_set_size(&v, *it);
+ for (const auto &item : value.get<Span<const Size>>())
+ gst_libcamera_gvalue_set_size(&v, item);
} else {
gst_libcamera_gvalue_set_size(&v, value.get<const Size>());
}
break;
case ControlTypePoint:
if (is_array) {
- Span<const Point> data = value.get<Span<const Point>>();
- for (auto it = data.begin(); it != data.end(); ++it)
- gst_libcamera_gvalue_set_point(&v, *it);
+ for (const auto &item : value.get<Span<const Point>>())
+ gst_libcamera_gvalue_set_point(&v, item);
} else {
gst_libcamera_gvalue_set_point(&v, value.get<const Point>());
}
break;
case ControlTypeRectangle:
if (is_array) {
- Span<const Rectangle> data = value.get<Span<const Rectangle>>();
- for (auto it = data.begin(); it != data.end(); ++it)
- gst_libcamera_gvalue_set_rectangle(&v, *it);
+ for (const auto &item : value.get<Span<const Rectangle>>())
+ gst_libcamera_gvalue_set_rectangle(&v, item);
} else {
gst_libcamera_gvalue_set_rectangle(&v, value.get<const Rectangle>());
}
@@ -45,10 +45,10 @@ int Agc::read(const libcamera::YamlObject ¶ms)
}
const auto &channels = params["channels"].asList();
- for (auto ch = channels.begin(); ch != channels.end(); ch++) {
+ for (const auto &ch : channels) {
LOG(RPiAgc, Debug) << "Read AGC channel";
channelData_.emplace_back();
- int ret = channelData_.back().channel.read(*ch, getHardwareConfig());
+ int ret = channelData_.back().channel.read(ch, getHardwareConfig());
if (ret)
return ret;
}
Use range-based for loops instead of iterators when iterating over a container. This improves readability. Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> --- include/libcamera/base/utils.h | 8 ++--- src/gstreamer/gstlibcamera-utils.cpp | 50 +++++++++++----------------- src/ipa/rpi/controller/rpi/agc.cpp | 4 +-- 3 files changed, 26 insertions(+), 36 deletions(-)