Skip to content
This repository has been archived by the owner on Dec 1, 2024. It is now read-only.

Commit

Permalink
NanUInt32OptionValue -> UInt32OptionValue
Browse files Browse the repository at this point in the history
  • Loading branch information
ralphtheninja committed May 12, 2015
1 parent 39c614a commit 56def2d
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 5 deletions.
10 changes: 10 additions & 0 deletions src/common.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,16 @@ NAN_INLINE bool BooleanOptionValue(v8::Local<v8::Object> options,
}
}

NAN_INLINE uint32_t UInt32OptionValue(v8::Local<v8::Object> options,
v8::Handle<v8::String> key,
uint32_t def) {
return !options.IsEmpty()
&& options->Has(key)
&& options->Get(key)->IsNumber()
? options->Get(key)->Uint32Value()
: def;
}

} // namespace leveldown

#endif
10 changes: 5 additions & 5 deletions src/database.cc
Original file line number Diff line number Diff line change
Expand Up @@ -197,27 +197,27 @@ NAN_METHOD(Database::Open) {
bool compression =
BooleanOptionValue(optionsObj, NanNew("compression"), true);

uint32_t cacheSize = NanUInt32OptionValue(
uint32_t cacheSize = UInt32OptionValue(
optionsObj
, NanNew("cacheSize")
, 8 << 20
);
uint32_t writeBufferSize = NanUInt32OptionValue(
uint32_t writeBufferSize = UInt32OptionValue(
optionsObj
, NanNew("writeBufferSize")
, 4 << 20
);
uint32_t blockSize = NanUInt32OptionValue(
uint32_t blockSize = UInt32OptionValue(
optionsObj
, NanNew("blockSize")
, 4096
);
uint32_t maxOpenFiles = NanUInt32OptionValue(
uint32_t maxOpenFiles = UInt32OptionValue(
optionsObj
, NanNew("maxOpenFiles")
, 1000
);
uint32_t blockRestartInterval = NanUInt32OptionValue(
uint32_t blockRestartInterval = UInt32OptionValue(
optionsObj
, NanNew("blockRestartInterval")
, 16
Expand Down

0 comments on commit 56def2d

Please sign in to comment.