On 07/09/2011 11:40 PM, Richard Heck wrote:
On 09/07/2011 02:17 PM, Julien Rioux wrote:
On 07/09/2011 7:04 PM, Richard Heck wrote:
On 09/07/2011 11:51 AM, Julien Rioux wrote:
On 07/09/2011 3:37 PM, Richard Heck wrote:
bool Format::dummy() const
@@ -101,6 +105,20 @@ bool Format::dummy() const
}


+bool Format::hasExtension(string const&  e) const
+{
+ if (extension().empty())
+ return false;
+ std::vector<string>::const_iterator it = extension_list_.begin();
+ std::vector<string>::const_iterator end = extension_list_.end();
+ for (; it != end; ++it) {
+ if ((*it) == e)
+ return true;
+ }
+ return false;
+}

This can be done more easily (and faster) with the std::find
algorithm.
Just:
return find(extension_list_.begin(), extension_list_.end(), e) !=
extension_list_.end();

Does your code only substitute the for loop, or can I also remove
if (extension().empty())
return false;
?

You can also remove that. In the empty case, it also returns end().

Richard



Thanks, done so now.

I haven't tested it, but I'll leave that to you. Looks good otherwise,
though.

rh




I'll probably put this in svn tomorrow or so.

--
Julien

Reply via email to