diff options
author | Laurent Pinchart <laurent.pinchart@ideasonboard.com> | 2020-03-23 12:33:30 +0200 |
---|---|---|
committer | Laurent Pinchart <laurent.pinchart@ideasonboard.com> | 2020-03-24 01:38:25 +0200 |
commit | 422e3e92ada16946dd3519f140edf51884bcca32 (patch) | |
tree | cf1229f4159179f404b807467fb32fc2011d3ad3 | |
parent | c153be4fecbe01364010fe4c6b5ce835e081d1c4 (diff) |
cam: main: Cache lookup of role property
The code handling the stream role option retrieves the role property and
converts it to a string in every branch. Cache it and use the cached
value.
Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
Reviewed-by: Niklas Söderlund <niklas.soderlund@ragnatech.se>
-rw-r--r-- | src/cam/main.cpp | 14 |
1 files changed, 8 insertions, 6 deletions
diff --git a/src/cam/main.cpp b/src/cam/main.cpp index 2a0a830f..7cdd215b 100644 --- a/src/cam/main.cpp +++ b/src/cam/main.cpp @@ -209,17 +209,19 @@ int CamApp::prepareConfig() for (auto const &value : streamOptions) { KeyValueParser::Options opt = value.toKeyValues(); - if (!opt.isSet("role")) { - roles.push_back(StreamRole::VideoRecording); - } else if (opt["role"].toString() == "viewfinder") { + std::string role = opt.isSet("role") + ? opt["role"].toString() + : "viewfinder"; + + if (role == "viewfinder") { roles.push_back(StreamRole::Viewfinder); - } else if (opt["role"].toString() == "video") { + } else if (role == "video") { roles.push_back(StreamRole::VideoRecording); - } else if (opt["role"].toString() == "still") { + } else if (role == "still") { roles.push_back(StreamRole::StillCapture); } else { std::cerr << "Unknown stream role " - << opt["role"].toString() << std::endl; + << role << std::endl; return -EINVAL; } } |