Cleanup: use find_if().
authorCarl Hetherington <cth@carlh.net>
Sun, 28 May 2023 00:12:03 +0000 (02:12 +0200)
committerCarl Hetherington <cth@carlh.net>
Sun, 28 May 2023 18:55:25 +0000 (20:55 +0200)
src/interop_subtitle_asset.cc

index 8fb115a73ee8a6eef4a6294dc3409f511ff45a57..0116c11c539a1a2d0390a6ac1003a6af9f8427b5 100644 (file)
@@ -214,13 +214,10 @@ InteropSubtitleAsset::write (boost::filesystem::path p) const
        /* Fonts */
        for (auto i: _load_font_nodes) {
                auto file = p.parent_path() / i->uri;
-               auto j = _fonts.begin();
-               while (j != _fonts.end() && j->load_id != i->id) {
-                       ++j;
-               }
-               if (j != _fonts.end ()) {
-                       j->data.write (file);
-                       j->file = file;
+               auto font_with_id = std::find_if(_fonts.begin(), _fonts.end(), [i](Font const& font) { return font.load_id == i->id; });
+               if (font_with_id != _fonts.end()) {
+                       font_with_id->data.write(file);
+                       font_with_id->file = file;
                }
        }
 }