From 48d6e8cf10618a398a85f3728f7a9243b4c57090 Mon Sep 17 00:00:00 2001 From: Dan Willemsen Date: Wed, 5 Aug 2015 14:38:34 -0700 Subject: [C++] Don't sort find/ls results These should only be sorted if explicitly requested, otherwise make-built binaries may be different from kati-built binaries. This resolves some binary-diff issues for Android between libc.a built with make vs kati/ninja. To be the same across multiple checkouts/machines, we should probably switch android to sorting these results, but then the kati ninja support will stop working. --- find.cc | 23 ++++++++++++----------- 1 file changed, 12 insertions(+), 11 deletions(-) (limited to 'find.cc') diff --git a/find.cc b/find.cc index 86f5dc2..dfd6838 100644 --- a/find.cc +++ b/find.cc @@ -23,7 +23,6 @@ #include #include -#include #include #include @@ -170,13 +169,15 @@ class DirentDirNode : public DirentNode { return this; size_t index = d.find('/'); const string& p = d.substr(0, index).as_string(); - auto found = children_.find(p); - if (found == children_.end()) - return NULL; - if (index == string::npos) - return found->second; - StringPiece nd = d.substr(index + 1); - return found->second->FindDir(nd); + for (auto& child : children_) { + if (p == child.first) { + if (index == string::npos) + return child.second; + StringPiece nd = d.substr(index + 1); + return child.second->FindDir(nd); + } + } + return NULL; } virtual bool RunFind(const FindCommand& fc, int d, @@ -205,12 +206,12 @@ class DirentDirNode : public DirentNode { } void Add(const string& name, DirentNode* c) { - auto p = children_.emplace(name, c); - CHECK(p.second); + auto p = children_.emplace(children_.end(), name, c); + CHECK(p->second); } private: - map children_; + vector> children_; }; class DirentSymlinkNode : public DirentNode { -- cgit v1.2.3