Permalink
Browse files

LruCache, refactor: use result of insert to check the element in map.

  • Loading branch information...
xicilion committed Sep 19, 2017
1 parent d27eb00 commit a286b7be6f58300d86c0269886b6eb180e1b3730
Showing with 4 additions and 3 deletions.
  1. +4 −3 fibjs/src/util/LruCache.cpp
@@ -118,9 +118,10 @@ result_t LruCache::get(exlib::string name, v8::Local<v8::Function> updater,
return CALL_E_JAVASCRIPT;
if (!IsEmpty(v)) {
find = m_datas.find(sname);
if (find == m_datas.end()) {
find = m_datas.insert(std::pair<exlib::string, _linkedNode>(sname, newNode)).first;
std::pair<std::map<exlib::string, _linkedNode>::iterator, bool> ret;
ret = m_datas.insert(std::pair<exlib::string, _linkedNode>(sname, newNode));
if (ret.second) {
find = ret.first;
insert(find);
find->second.insert.now();

0 comments on commit a286b7b

Please sign in to comment.