* limitations under the License.
*/
-#include "folly/experimental/symbolizer/ElfCache.h"
+#include <folly/experimental/symbolizer/ElfCache.h>
namespace folly { namespace symbolizer {
ElfCache::ElfCache(size_t capacity) : capacity_(capacity) { }
std::shared_ptr<ElfFile> ElfCache::getFile(StringPiece p) {
- auto path = p.str();
-
std::lock_guard<std::mutex> lock(mutex_);
- auto pos = files_.find(path);
+ auto pos = files_.find(p);
if (pos != files_.end()) {
// Found, move to back (MRU)
auto& entry = pos->second;
}
auto entry = std::make_shared<Entry>();
+ entry->path = p.str();
+ auto& path = entry->path;
// No negative caching
if (entry->file.openNoThrow(path.c_str()) == -1) {
}
if (files_.size() == capacity_) {
- // Evict LRU
+ auto& e = lruList_.front();
lruList_.pop_front();
+ files_.erase(e.path);
}
- files_.emplace(std::move(path), entry);
+ files_.emplace(entry->path, entry);
lruList_.push_back(*entry);
return filePtr(entry);