Skip to content

Commit 3fe0cf4

Browse files
author
Clement Champetier
committed
ProfileLoader: clean update
* Check if 'avProfileIdentificator' key exist in map. * Do nothing if profile already exists.
1 parent 3307d22 commit 3fe0cf4

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

src/AvTranscoder/ProfileLoader.cpp

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -85,15 +85,17 @@ void ProfileLoader::loadProfiles( const std::string& avProfilesPath )
8585

8686
void ProfileLoader::update( const Profile& profile )
8787
{
88-
std::string profileId( profile.find( constants::avProfileIdentificator )->second );
88+
Profile::const_iterator profileIt = profile.find( constants::avProfileIdentificator );
89+
if( profileIt == profile.end() )
90+
throw std::runtime_error( "Invalid profile: can't get identificator" );
91+
92+
std::string profileId( profileIt->second );
8993
size_t profileIndex = 0;
9094
for( Profiles::iterator it = _profiles.begin(); it != _profiles.end(); ++it )
9195
{
96+
// profile already exists
9297
if( (*it).find( constants::avProfileIdentificator )->second == profileId )
93-
{
94-
_profiles.at( profileIndex ) = profile;
9598
return;
96-
}
9799
++profileIndex;
98100
}
99101
// profile not found: add the new profile

0 commit comments

Comments
 (0)