From 21e9bd77598f7bb4588ca9b16a58667e3340f6d9 Mon Sep 17 00:00:00 2001 From: Carl Hetherington Date: Sun, 1 Jun 2025 01:37:31 +0200 Subject: Cleanup: compress some ifs. --- src/lib/film.cc | 3 +-- src/lib/video_content.cc | 9 +++------ 2 files changed, 4 insertions(+), 8 deletions(-) diff --git a/src/lib/film.cc b/src/lib/film.cc index d0a26e44c..9897a01bf 100644 --- a/src/lib/film.cc +++ b/src/lib/film.cc @@ -579,8 +579,7 @@ Film::read_metadata(optional path) } { - auto c = f.optional_string_child("Container"); - if (c) { + if (auto c = f.optional_string_child("Container")) { _container = Ratio::from_id(c.get()); } } diff --git a/src/lib/video_content.cc b/src/lib/video_content.cc index dcce499cb..d0c6c850a 100644 --- a/src/lib/video_content.cc +++ b/src/lib/video_content.cc @@ -123,17 +123,15 @@ VideoContent::VideoContent(Content* parent, cxml::ConstNodePtr node, int version _crop.bottom = node->number_child("BottomCrop"); if (version <= 7) { - auto r = node->optional_string_child("Ratio"); - if (r) { _legacy_ratio = Ratio::from_id(r.get())->ratio(); + if (auto r = node->optional_string_child("Ratio")) { } } else if (version <= 37) { auto ratio = node->node_child("Scale")->optional_string_child("Ratio"); if (ratio) { _legacy_ratio = Ratio::from_id(ratio.get())->ratio(); } - auto scale = node->node_child("Scale")->optional_bool_child("Scale"); - if (scale) { + if (auto scale = node->node_child("Scale")->optional_bool_child("Scale")) { if (*scale) { /* This is what we used to call "no stretch" */ DCPOMATIC_ASSERT(_size); @@ -181,8 +179,7 @@ VideoContent::VideoContent(Content* parent, cxml::ConstNodePtr node, int version _pixel_quanta = PixelQuanta(pixel_quanta); } - auto burnt = node->optional_string_child("BurntSubtitleLanguage"); - if (burnt) { + if (auto burnt = node->optional_string_child("BurntSubtitleLanguage")) { _burnt_subtitle_language = dcp::LanguageTag(*burnt); } -- cgit v1.2.3