aboutsummaryrefslogtreecommitdiff
path: root/find.cc
diff options
context:
space:
mode:
authorDan Willemsen <dwillemsen@google.com>2015-08-05 14:38:34 -0700
committerDan Willemsen <dwillemsen@google.com>2015-08-05 15:05:50 -0700
commit48d6e8cf10618a398a85f3728f7a9243b4c57090 (patch)
tree577c42b703ab141f4c1af42be947dbbc5ab7a7fd /find.cc
parenta06bee9cb929c2e0646154c6803c3c32565ca6eb (diff)
downloadkati-48d6e8cf10618a398a85f3728f7a9243b4c57090.tar.gz
[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.
Diffstat (limited to 'find.cc')
-rw-r--r--find.cc23
1 files changed, 12 insertions, 11 deletions
diff --git a/find.cc b/find.cc
index 86f5dc2..dfd6838 100644
--- a/find.cc
+++ b/find.cc
@@ -23,7 +23,6 @@
#include <sys/types.h>
#include <unistd.h>
-#include <map>
#include <memory>
#include <vector>
@@ -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<string, DirentNode*> children_;
+ vector<pair<string, DirentNode*>> children_;
};
class DirentSymlinkNode : public DirentNode {