dump(): Use emplace()

This commit is contained in:
Eelco Dolstra 2021-12-02 20:56:26 +01:00
parent e1a0359b59
commit fcddaa4b9b

View file

@ -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)); debug(format("removing case hack suffix from '%1%'") % (path + "/" + i.name));
name.erase(pos); 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%'", throw Error("file name collision in between '%1%' and '%2%'",
(path + "/" + unhacked[name]), (path + "/" + unhacked[name]),
(path + "/" + i.name)); (path + "/" + i.name));
unhacked[name] = i.name;
} else } else
unhacked[i.name] = i.name; unhacked.emplace(i.name, i.name);
for (auto & i : unhacked) for (auto & i : unhacked)
if (filter(path + "/" + i.first)) { if (filter(path + "/" + i.first)) {