/*
- * Copyright 2016 Facebook, Inc.
+ * Copyright 2017 Facebook, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
// own wrapper around a fixed-size, null-terminated string.
class Path : private boost::totally_ordered<Path> {
public:
+ Path() {
+ assign(folly::StringPiece());
+ }
+
explicit Path(StringPiece s) {
+ assign(s);
+ }
+
+ void assign(StringPiece s) {
DCHECK_LE(s.size(), kMaxSize);
- memcpy(data_, s.data(), s.size());
+ if (!s.empty()) {
+ memcpy(data_, s.data(), s.size());
+ }
data_[s.size()] = '\0';
}
char data_[kMaxSize + 1];
};
+ Path scratchpad_; // Preallocated key for map_ lookups.
boost::container::flat_map<Path, int> map_;
std::vector<std::shared_ptr<ElfFile>> slots_;
};