Skip to contentSkip to conversation

utils: replace push_back with emplace_back

PATCH New Rosen Penev 1 participant 1 message Aug 17, 2021 Media (V4L/DVB)

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 utils: replace push_back with emplace_back

Avoids having to call the constructor as it forwards the arguments directly.

---
 utils/v4l2-compliance/v4l2-test-buffers.cpp | 2 +-
 utils/v4l2-ctl/v4l2-ctl-common.cpp          | 4 ++--
 2 files changed, 3 insertions(+), 3 deletions(-)
utils/v4l2-compliance/v4l2-test-buffers.cpp +1 -1
index 197baaeb7..e6a0630d9 100644
@@ -3058,7 +3058,7 @@ static void streamFmt(struct node *node, __u32 pixelformat, __u32 w, __u32 h,
 
 	selTest test = createSelTest(node);
 	if (!haveSelTest(test)) 
-		selTests.push_back(createSelTest(node));
+		selTests.push_back(test);
 
 	for (unsigned i = 0; i < 8; i++) {
 		v4l2_selection *sel1 = selections[node->can_output][i & 1];
utils/v4l2-ctl/v4l2-ctl-common.cpp +2 -2
index 51919fa71..c94017149 100644
@@ -996,8 +996,8 @@ void common_cmd(const std::string &media_bus_info, int ch, char *optarg)
 				std::exit(EXIT_FAILURE);
 			}
 			if (const char *equal = std::strchr(value, '=')) {
-				set_ctrls.push_back(std::make_pair(std::string(value, (equal - value)),
-								   std::string(equal + 1)));
+				set_ctrls.emplace_back(std::string(value, (equal - value)),
+						       std::string(equal + 1));
 			}
 			else {
 				fprintf(stderr, "control '%s' without '='\n", value);
Signature · 1 line
2.31.1