X-Git-Url: http://git.tdb.fi/?a=blobdiff_plain;f=source%2Fbuildinfo.cpp;h=77243ef365ffcb2cc6b82868c852ae04bfe0e757;hb=ee2c6758fd120fe8bca76521acba06d793121d60;hp=ec8156798d70628d0597e6936ecd39622d9fff58;hpb=50be4619cca4bb44e5abf8759720c255ef6d3b45;p=builder.git diff --git a/source/buildinfo.cpp b/source/buildinfo.cpp index ec81567..77243ef 100644 --- a/source/buildinfo.cpp +++ b/source/buildinfo.cpp @@ -1,4 +1,5 @@ #include +#include #include "buildinfo.h" using namespace std; @@ -7,17 +8,18 @@ using namespace Msp; namespace { /** Removes any duplicate entries from a list, leaving only the first one. The -order of other elements is preserved. O(n²) efficiency. */ -void unique(StringList &l) +order of other elements is preserved. O(nlogn) efficiency. */ +template +void unique(list &l) { - for(StringList::iterator i=l.begin(); i!=l.end(); ++i) - for(StringList::iterator j=i; j!=l.end();) - { - if(j!=i && *j==*i) - j = l.erase(j); - else - ++j; - } + set seen; + for(typename list::iterator i=l.begin(); i!=l.end(); ) + { + if(seen.count(*i)) + l.erase(i++); + else + seen.insert(*i++); + } } }