Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit e4450a1

Browse filesBrowse files
addaleaxBethGriggs
authored andcommitted
benchmark: update function_args addon code
Make the code linter-conformant and remove usage of deprecated APIs. PR-URL: #34725 Reviewed-By: Richard Lau <riclau@uk.ibm.com> Reviewed-By: James M Snell <jasnell@gmail.com>
1 parent ea98122 commit e4450a1
Copy full SHA for e4450a1

File tree

Expand file treeCollapse file tree

1 file changed

+16
-16
lines changed
Open diff view settings
Filter options
Expand file treeCollapse file tree

1 file changed

+16
-16
lines changed
Open diff view settings
Collapse file

‎benchmark/napi/function_args/binding.cc‎

Copy file name to clipboardExpand all lines: benchmark/napi/function_args/binding.cc
+16-16Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -2,18 +2,20 @@
22
#include <node.h>
33
#include <assert.h>
44

5-
using v8::Isolate;
5+
using v8::Array;
6+
using v8::ArrayBuffer;
7+
using v8::ArrayBufferView;
8+
using v8::BackingStore;
69
using v8::Context;
10+
using v8::FunctionCallbackInfo;
11+
using v8::Isolate;
712
using v8::Local;
813
using v8::MaybeLocal;
9-
using v8::Value;
1014
using v8::Number;
11-
using v8::String;
1215
using v8::Object;
13-
using v8::Array;
14-
using v8::ArrayBufferView;
15-
using v8::ArrayBuffer;
16-
using v8::FunctionCallbackInfo;
16+
using v8::String;
17+
using v8::Uint32;
18+
using v8::Value;
1719

1820
void CallWithString(const FunctionCallbackInfo<Value>& args) {
1921
assert(args.Length() == 1 && args[0]->IsString());
@@ -22,7 +24,7 @@ void CallWithString(const FunctionCallbackInfo<Value>& args) {
2224
const int32_t length = str->Utf8Length(args.GetIsolate()) + 1;
2325
char* buf = new char[length];
2426
str->WriteUtf8(args.GetIsolate(), buf, length);
25-
delete [] buf;
27+
delete[] buf;
2628
}
2729
}
2830

@@ -31,7 +33,7 @@ void CallWithArray(const FunctionCallbackInfo<Value>& args) {
3133
if (args.Length() == 1 && args[0]->IsArray()) {
3234
const Local<Array> array = args[0].As<Array>();
3335
uint32_t length = array->Length();
34-
for (uint32_t i = 0; i < length; ++ i) {
36+
for (uint32_t i = 0; i < length; i++) {
3537
Local<Value> v;
3638
v = array->Get(args.GetIsolate()->GetCurrentContext(),
3739
i).ToLocalChecked();
@@ -101,24 +103,22 @@ void CallWithTypedarray(const FunctionCallbackInfo<Value>& args) {
101103
const size_t byte_length = view->ByteLength();
102104
assert(byte_length > 0);
103105
assert(view->HasBuffer());
104-
Local<ArrayBuffer> buffer;
105-
buffer = view->Buffer();
106-
ArrayBuffer::Contents contents;
107-
contents = buffer->GetContents();
106+
Local<ArrayBuffer> buffer = view->Buffer();
107+
std::shared_ptr<BackingStore> bs = buffer->GetBackingStore();
108108
const uint32_t* data = reinterpret_cast<uint32_t*>(
109-
static_cast<uint8_t*>(contents.Data()) + byte_offset);
109+
static_cast<uint8_t*>(bs->Data()) + byte_offset);
110110
assert(data);
111111
}
112112
}
113113

114114
void CallWithArguments(const FunctionCallbackInfo<Value>& args) {
115115
assert(args.Length() > 1 && args[0]->IsNumber());
116116
if (args.Length() > 1 && args[0]->IsNumber()) {
117-
int32_t loop = args[0].As<v8::Uint32>()->Value();
117+
int32_t loop = args[0].As<Uint32>()->Value();
118118
for (int32_t i = 1; i < loop; ++i) {
119119
assert(i < args.Length());
120120
assert(args[i]->IsUint32());
121-
args[i].As<v8::Uint32>()->Value();
121+
args[i].As<Uint32>()->Value();
122122
}
123123
}
124124
}

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.