From fcddaa4b9b22a910a24a513bc05579a12eb1db41 Mon Sep 17 00:00:00 2001 From: Eelco Dolstra Date: Thu, 2 Dec 2021 20:56:26 +0100 Subject: [PATCH] dump(): Use emplace() --- src/libutil/archive.cc | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/src/libutil/archive.cc b/src/libutil/archive.cc index d78ec2b93..fdee643b1 100644 --- a/src/libutil/archive.cc +++ b/src/libutil/archive.cc @@ -93,13 +93,12 @@ static void dump(const Path & path, Sink & sink, PathFilter & filter) debug(format("removing case hack suffix from '%1%'") % (path + "/" + i.name)); name.erase(pos); } - if (unhacked.find(name) != unhacked.end()) + if (!unhacked.emplace(name, i.name).second) throw Error("file name collision in between '%1%' and '%2%'", (path + "/" + unhacked[name]), (path + "/" + i.name)); - unhacked[name] = i.name; } else - unhacked[i.name] = i.name; + unhacked.emplace(i.name, i.name); for (auto & i : unhacked) if (filter(path + "/" + i.first)) {