From 595d4fbfee788edfad7f9f8dfe7e76ee634c1a94 Mon Sep 17 00:00:00 2001 From: Carl Hetherington Date: Tue, 22 Jul 2014 00:49:15 +0100 Subject: Various attempts to clean up DCP comparison code. --- src/dcp.cc | 26 ++++++++++++++++---------- 1 file changed, 16 insertions(+), 10 deletions(-) (limited to 'src/dcp.cc') diff --git a/src/dcp.cc b/src/dcp.cc index c92a14b8..ca1c23d9 100644 --- a/src/dcp.cc +++ b/src/dcp.cc @@ -50,6 +50,7 @@ using std::string; using std::list; +using std::cout; using std::stringstream; using std::ostream; using std::make_pair; @@ -174,23 +175,28 @@ DCP::read (bool keep_going, ReadErrors* errors) bool DCP::equals (DCP const & other, EqualityOptions opt, boost::function note) const { - if (_assets.size() != other._assets.size()) { - note (DCP_ERROR, String::compose ("Asset counts differ: %1 vs %2", _assets.size(), other._assets.size())); + list > a = cpls (); + list > b = other.cpls (); + + if (a.size() != b.size()) { + note (DCP_ERROR, String::compose ("CPL counts differ: %1 vs %2", a.size(), b.size())); return false; } - list >::const_iterator a = _assets.begin (); - list >::const_iterator b = other._assets.begin (); + bool r = true; + + for (list >::const_iterator i = a.begin(); i != a.end(); ++i) { + list >::const_iterator j = b.begin (); + while (j != b.end() && !(*j)->equals (*i, opt, note)) { + ++j; + } - while (a != _assets.end ()) { - if (!(*a)->equals (*b, opt, note)) { - return false; + if (j == b.end ()) { + r = false; } - ++a; - ++b; } - return true; + return r; } void -- cgit v1.2.3