diff options
author | Anna Henningsen <anna@addaleax.net> | 2020-08-11 16:31:17 +0300 |
---|---|---|
committer | James M Snell <jasnell@gmail.com> | 2020-08-11 23:29:14 +0300 |
commit | 9dac8cbbc32cac824cc8415df3b610cee6d47c99 (patch) | |
tree | b95e858ea962901a1d6df049c0a11c5173f5d7d0 /benchmark | |
parent | bbdb0133dc084cdb5107a56b48b7c5fdb0deeec9 (diff) |
benchmark: update function_args addon code
Make the code linter-conformant and remove usage of deprecated APIs.
PR-URL: https://github.com/nodejs/node/pull/34725
Reviewed-By: Richard Lau <riclau@uk.ibm.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Diffstat (limited to 'benchmark')
-rw-r--r-- | benchmark/napi/function_args/binding.cc | 32 |
1 files changed, 16 insertions, 16 deletions
diff --git a/benchmark/napi/function_args/binding.cc b/benchmark/napi/function_args/binding.cc index 9f250aaa83d..2c54dd424d4 100644 --- a/benchmark/napi/function_args/binding.cc +++ b/benchmark/napi/function_args/binding.cc @@ -2,18 +2,20 @@ #include <node.h> #include <assert.h> -using v8::Isolate; +using v8::Array; +using v8::ArrayBuffer; +using v8::ArrayBufferView; +using v8::BackingStore; using v8::Context; +using v8::FunctionCallbackInfo; +using v8::Isolate; using v8::Local; using v8::MaybeLocal; -using v8::Value; using v8::Number; -using v8::String; using v8::Object; -using v8::Array; -using v8::ArrayBufferView; -using v8::ArrayBuffer; -using v8::FunctionCallbackInfo; +using v8::String; +using v8::Uint32; +using v8::Value; void CallWithString(const FunctionCallbackInfo<Value>& args) { assert(args.Length() == 1 && args[0]->IsString()); @@ -22,7 +24,7 @@ void CallWithString(const FunctionCallbackInfo<Value>& args) { const int32_t length = str->Utf8Length(args.GetIsolate()) + 1; char* buf = new char[length]; str->WriteUtf8(args.GetIsolate(), buf, length); - delete [] buf; + delete[] buf; } } @@ -31,7 +33,7 @@ void CallWithArray(const FunctionCallbackInfo<Value>& args) { if (args.Length() == 1 && args[0]->IsArray()) { const Local<Array> array = args[0].As<Array>(); uint32_t length = array->Length(); - for (uint32_t i = 0; i < length; ++ i) { + for (uint32_t i = 0; i < length; i++) { Local<Value> v; v = array->Get(args.GetIsolate()->GetCurrentContext(), i).ToLocalChecked(); @@ -101,12 +103,10 @@ void CallWithTypedarray(const FunctionCallbackInfo<Value>& args) { const size_t byte_length = view->ByteLength(); assert(byte_length > 0); assert(view->HasBuffer()); - Local<ArrayBuffer> buffer; - buffer = view->Buffer(); - ArrayBuffer::Contents contents; - contents = buffer->GetContents(); + Local<ArrayBuffer> buffer = view->Buffer(); + std::shared_ptr<BackingStore> bs = buffer->GetBackingStore(); const uint32_t* data = reinterpret_cast<uint32_t*>( - static_cast<uint8_t*>(contents.Data()) + byte_offset); + static_cast<uint8_t*>(bs->Data()) + byte_offset); assert(data); } } @@ -114,11 +114,11 @@ void CallWithTypedarray(const FunctionCallbackInfo<Value>& args) { void CallWithArguments(const FunctionCallbackInfo<Value>& args) { assert(args.Length() > 1 && args[0]->IsNumber()); if (args.Length() > 1 && args[0]->IsNumber()) { - int32_t loop = args[0].As<v8::Uint32>()->Value(); + int32_t loop = args[0].As<Uint32>()->Value(); for (int32_t i = 1; i < loop; ++i) { assert(i < args.Length()); assert(args[i]->IsUint32()); - args[i].As<v8::Uint32>()->Value(); + args[i].As<Uint32>()->Value(); } } } |