summaryrefslogtreecommitdiffstats
path: root/third_party
diff options
context:
space:
mode:
authorcmumford <cmumford@chromium.org>2014-10-02 17:34:34 -0700
committerCommit bot <commit-bot@chromium.org>2014-10-03 00:35:54 +0000
commite90bb8d5255515e8719c0c4b685f5f122fed1fcb (patch)
treefe2d3d4eab8e2c096069c3e74d7b252838134070 /third_party
parent81b6e760f33550cc61ee5b80b25b0ea773b4d1d5 (diff)
downloadchromium_src-e90bb8d5255515e8719c0c4b685f5f122fed1fcb.zip
chromium_src-e90bb8d5255515e8719c0c4b685f5f122fed1fcb.tar.gz
chromium_src-e90bb8d5255515e8719c0c4b685f5f122fed1fcb.tar.bz2
LevelDB: Converted map (not using map val) to set.
Chrome's LevelDB environment used a std::map to maintain a list of directories in need of a fsync, but the value was never used - only the key. Converted to a std::set for less heap usage, greater clarity and efficiency. Review URL: https://codereview.chromium.org/513733003 Cr-Commit-Position: refs/heads/master@{#297961}
Diffstat (limited to 'third_party')
-rw-r--r--third_party/leveldatabase/env_chromium.cc13
-rw-r--r--third_party/leveldatabase/env_chromium.h5
2 files changed, 9 insertions, 9 deletions
diff --git a/third_party/leveldatabase/env_chromium.cc b/third_party/leveldatabase/env_chromium.cc
index 7f0d45d..76f081f 100644
--- a/third_party/leveldatabase/env_chromium.cc
+++ b/third_party/leveldatabase/env_chromium.cc
@@ -12,6 +12,7 @@
#include "base/files/file_util.h"
#include "base/lazy_instance.h"
#include "base/metrics/histogram.h"
+#include "base/stl_util.h"
#include "base/strings/utf_string_conversions.h"
#include "third_party/leveldatabase/env_chromium_stdio.h"
#include "third_party/re2/re2/re2.h"
@@ -831,18 +832,18 @@ static std::string GetDirName(const std::string& filename) {
}
void ChromiumEnv::DidCreateNewFile(const std::string& filename) {
- base::AutoLock auto_lock(map_lock_);
- needs_sync_map_[GetDirName(filename)] = true;
+ base::AutoLock auto_lock(directory_sync_lock_);
+ directories_needing_sync_.insert(GetDirName(filename));
}
bool ChromiumEnv::DoesDirNeedSync(const std::string& filename) {
- base::AutoLock auto_lock(map_lock_);
- return needs_sync_map_.find(GetDirName(filename)) != needs_sync_map_.end();
+ base::AutoLock auto_lock(directory_sync_lock_);
+ return ContainsKey(directories_needing_sync_, GetDirName(filename));
}
void ChromiumEnv::DidSyncDir(const std::string& filename) {
- base::AutoLock auto_lock(map_lock_);
- needs_sync_map_.erase(GetDirName(filename));
+ base::AutoLock auto_lock(directory_sync_lock_);
+ directories_needing_sync_.erase(GetDirName(filename));
}
} // namespace leveldb_env
diff --git a/third_party/leveldatabase/env_chromium.h b/third_party/leveldatabase/env_chromium.h
index 4ce3190..b340c26 100644
--- a/third_party/leveldatabase/env_chromium.h
+++ b/third_party/leveldatabase/env_chromium.h
@@ -6,7 +6,6 @@
#define THIRD_PARTY_LEVELDATABASE_ENV_CHROMIUM_H_
#include <deque>
-#include <map>
#include <set>
#include <string>
#include <vector>
@@ -169,8 +168,8 @@ class ChromiumEnv : public leveldb::Env,
std::set<std::string> locked_files_;
};
- std::map<std::string, bool> needs_sync_map_;
- base::Lock map_lock_;
+ std::set<std::string> directories_needing_sync_;
+ base::Lock directory_sync_lock_;
const int kMaxRetryTimeMillis;
// BGThread() is the body of the background thread