Skip to content

Commit

Permalink
Only need to set filterPolicy once when Database object is created
Browse files Browse the repository at this point in the history
  • Loading branch information
ralphtheninja committed Dec 15, 2018
1 parent 8855749 commit 6aca8c8
Showing 1 changed file with 1 addition and 9 deletions.
10 changes: 1 addition & 9 deletions binding.cc
Original file line number Diff line number Diff line change
Expand Up @@ -320,7 +320,7 @@ struct Database {
: env_(env),
db_(NULL),
blockCache_(NULL),
filterPolicy_(NULL),
filterPolicy_(leveldb::NewBloomFilterPolicy(10)),
currentIteratorId_(0),
pendingCloseWorker_(NULL) {}

Expand All @@ -343,10 +343,6 @@ struct Database {
delete blockCache_;
blockCache_ = NULL;
}
if (filterPolicy_) {
delete filterPolicy_;
filterPolicy_ = NULL;
}
}

leveldb::Status Put (const leveldb::WriteOptions& options,
Expand Down Expand Up @@ -409,9 +405,6 @@ struct Database {
napi_env env_;
leveldb::DB* db_;
leveldb::Cache* blockCache_;
// TODO figure out if we can use filterPolicy_ across
// several Open()/Close(), i.e. can we create it _one_
// time in the constructor?
const leveldb::FilterPolicy* filterPolicy_;
uint32_t currentIteratorId_;
BaseWorker *pendingCloseWorker_;
Expand Down Expand Up @@ -757,7 +750,6 @@ NAPI_METHOD(db_open) {
uint32_t maxFileSize = Uint32Property(env, options, "maxFileSize", 2 << 20);

database->blockCache_ = leveldb::NewLRUCache(cacheSize);
database->filterPolicy_ = leveldb::NewBloomFilterPolicy(10);

napi_value callback = argv[3];
OpenWorker* worker = new OpenWorker(env,
Expand Down

0 comments on commit 6aca8c8

Please sign in to comment.