From df9757124d8e12c0fbf39803f3d3e8057262f353 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Hugo=20Beauz=C3=A9e-Luyssen?= Date: Thu, 24 Nov 2011 11:52:44 +0100 Subject: [PATCH] dash: Avoid multiple lookups. MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Signed-off-by: Rémi Denis-Courmont --- modules/stream_filter/dash/mpd/MPD.cpp | 16 ++++++++++------ modules/stream_filter/dash/mpd/MPD.h | 4 +++- 2 files changed, 13 insertions(+), 7 deletions(-) diff --git a/modules/stream_filter/dash/mpd/MPD.cpp b/modules/stream_filter/dash/mpd/MPD.cpp index 69b4c05f17..cb8c7e0722 100644 --- a/modules/stream_filter/dash/mpd/MPD.cpp +++ b/modules/stream_filter/dash/mpd/MPD.cpp @@ -60,24 +60,28 @@ std::vector MPD::getBaseUrls () } std::string MPD::getMinBufferTime () throw(AttributeNotPresentException) { - if(this->attributes.find("minBufferTime") == this->attributes.end()) + AttributesMap::iterator it = this->attributes.find("minBufferTime"); + if( it == this->attributes.end()) throw AttributeNotPresentException(); - return this->attributes["minBufferTime"]; + return it->second; } std::string MPD::getType () throw(AttributeNotPresentException) { - if(this->attributes.find("type") == this->attributes.end()) + AttributesMap::iterator it = this->attributes.find( "type" ); + if( it == this->attributes.end() ) throw AttributeNotPresentException(); - return this->attributes["type"]; + return it->second; } std::string MPD::getDuration () throw(AttributeNotPresentException) { - if(this->attributes.find("mediaPresentationDuration") == this->attributes.end()) + AttributesMap::iterator it = this->attributes.find("mediaPresentationDuration"); + + if( it == this->attributes.end()) throw AttributeNotPresentException(); - return this->attributes["mediaPresentationDuration"]; + return it->second; } ProgramInformation* MPD::getProgramInformation () throw(ElementNotPresentException) { diff --git a/modules/stream_filter/dash/mpd/MPD.h b/modules/stream_filter/dash/mpd/MPD.h index 732d38b3ad..2942b18274 100644 --- a/modules/stream_filter/dash/mpd/MPD.h +++ b/modules/stream_filter/dash/mpd/MPD.h @@ -41,6 +41,8 @@ namespace dash { class MPD { + typedef std::map AttributesMap; + public: MPD (std::map attributes); MPD (); @@ -58,7 +60,7 @@ namespace dash void setProgramInformation (ProgramInformation *progInfo); private: - std::map attributes; + AttributesMap attributes; std::vector periods; std::vector baseUrls; ProgramInformation *programInfo; -- 2.39.2