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;
?
--
Julien