From 56def2d7c8a53e8af5b36aa635a00bf487aac8c8 Mon Sep 17 00:00:00 2001 From: Lars-Magnus Skog Date: Sat, 9 May 2015 14:19:10 +0200 Subject: [PATCH] NanUInt32OptionValue -> UInt32OptionValue --- src/common.h | 10 ++++++++++ src/database.cc | 10 +++++----- 2 files changed, 15 insertions(+), 5 deletions(-) diff --git a/src/common.h b/src/common.h index fd5d28ce..78b9de3d 100644 --- a/src/common.h +++ b/src/common.h @@ -24,6 +24,16 @@ NAN_INLINE bool BooleanOptionValue(v8::Local options, } } +NAN_INLINE uint32_t UInt32OptionValue(v8::Local options, + v8::Handle key, + uint32_t def) { + return !options.IsEmpty() + && options->Has(key) + && options->Get(key)->IsNumber() + ? options->Get(key)->Uint32Value() + : def; +} + } // namespace leveldown #endif diff --git a/src/database.cc b/src/database.cc index 93d362dd..c662a38a 100644 --- a/src/database.cc +++ b/src/database.cc @@ -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