From: Rosen Penev Date: Mon, 26 Sep 2022 22:59:28 +0000 (-0700) Subject: further simplify X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=4325406e460f06cb228c31e3b95bf342438e5e26;p=libmatroska further simplify Signed-off-by: Rosen Penev --- diff --git a/src/KaxSeekHead.cpp b/src/KaxSeekHead.cpp index 5941f9f..304cad8 100644 --- a/src/KaxSeekHead.cpp +++ b/src/KaxSeekHead.cpp @@ -85,23 +85,17 @@ KaxSeek * KaxSeekHead::FindFirstOf(const EbmlCallbacks & Callbacks) const KaxSeek * KaxSeekHead::FindNextOf(const KaxSeek &aPrev) const { - EBML_MASTER_CONST_ITERATOR Itr; - KaxSeek *tmp; - // look for the previous in the list - auto it = std::find_if(this->begin(), this->end(), [&](auto e){ return e == static_cast(&aPrev); }); - if (it != end()) { - ++it; - for (; it != end(); ++it) { - if (EbmlId(*(*it)) == EBML_ID(KaxSeek)) { - tmp = static_cast(*it); - if (tmp->IsEbmlId(aPrev)) - return tmp; - } - } - } + auto it = std::find(this->begin(), this->end(), static_cast(&aPrev)); + if (it == this->end()) + return nullptr; - return nullptr; + auto it2 = std::find_if(it + 1, this->end(), [&](auto e) + { return (EbmlId(*(*it)) == EBML_ID(KaxSeek)) && static_cast(e)->IsEbmlId(aPrev); }); + if (it2 == this->end()) + return nullptr; + + return static_cast(*it2); } int64 KaxSeek::Location() const