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 d1fb8a5

Browse filesBrowse files
addaleaxaduh95
authored andcommitted
src: avoid unnecessary string -> char* -> string round trips
In these places we can just generate `std::string` directly, so there's no need to convert to an intermediate C string. PR-URL: #60055 Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Luigi Pinca <luigipinca@gmail.com> Reviewed-By: Chengzhong Wu <legendecas@gmail.com>
1 parent df72dc9 commit d1fb8a5
Copy full SHA for d1fb8a5

File tree

Expand file treeCollapse file tree

6 files changed

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

6 files changed

+10
-12
lines changed
Open diff view settings
Collapse file

‎src/inspector/protocol_helper.h‎

Copy file name to clipboardExpand all lines: src/inspector/protocol_helper.h
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ inline std::unique_ptr<v8_inspector::StringBuffer> ToInspectorString(
1919
inline protocol::String ToProtocolString(v8::Isolate* isolate,
2020
v8::Local<v8::Value> value) {
2121
Utf8Value buffer(isolate, value);
22-
return *buffer;
22+
return buffer.ToString();
2323
}
2424

2525
} // namespace node::inspector
Collapse file

‎src/node_blob.cc‎

Copy file name to clipboardExpand all lines: src/node_blob.cc
+3-5Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -439,11 +439,9 @@ void Blob::StoreDataObject(const FunctionCallbackInfo<Value>& args) {
439439
Utf8Value type(isolate, args[3]);
440440

441441
binding_data->store_data_object(
442-
std::string(*key, key.length()),
442+
key.ToString(),
443443
BlobBindingData::StoredDataObject(
444-
BaseObjectPtr<Blob>(blob),
445-
length,
446-
std::string(*type, type.length())));
444+
BaseObjectPtr<Blob>(blob), length, type.ToString()));
447445
}
448446

449447
// Note: applying the V8 Fast API to the following function does not produce
@@ -483,7 +481,7 @@ void Blob::GetDataObject(const FunctionCallbackInfo<Value>& args) {
483481
Utf8Value key(isolate, args[0]);
484482

485483
BlobBindingData::StoredDataObject stored =
486-
binding_data->get_data_object(std::string(*key, key.length()));
484+
binding_data->get_data_object(key.ToString());
487485
if (stored.blob) {
488486
Local<Value> type;
489487
if (!String::NewFromUtf8(isolate,
Collapse file

‎src/node_contextify.cc‎

Copy file name to clipboardExpand all lines: src/node_contextify.cc
+2-2Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -292,10 +292,10 @@ BaseObjectPtr<ContextifyContext> ContextifyContext::New(
292292
options->allow_code_gen_wasm);
293293

294294
Utf8Value name_val(env->isolate(), options->name);
295-
ContextInfo info(*name_val);
295+
ContextInfo info(name_val.ToString());
296296
if (!options->origin.IsEmpty()) {
297297
Utf8Value origin_val(env->isolate(), options->origin);
298-
info.origin = *origin_val;
298+
info.origin = origin_val.ToString();
299299
}
300300

301301
BaseObjectPtr<ContextifyContext> result;
Collapse file

‎src/node_errors.h‎

Copy file name to clipboardExpand all lines: src/node_errors.h
+2-2Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -268,12 +268,12 @@ inline void THROW_ERR_REQUIRE_ASYNC_MODULE(
268268
if (!parent_filename.IsEmpty() && parent_filename->IsString()) {
269269
Utf8Value utf8(env->isolate(), parent_filename);
270270
message += "\n From ";
271-
message += utf8.out();
271+
message += utf8.ToStringView();
272272
}
273273
if (!filename.IsEmpty() && filename->IsString()) {
274274
Utf8Value utf8(env->isolate(), filename);
275275
message += "\n Requiring ";
276-
message += +utf8.out();
276+
message += utf8.ToStringView();
277277
}
278278
THROW_ERR_REQUIRE_ASYNC_MODULE(env, message.c_str());
279279
}
Collapse file

‎src/node_messaging.cc‎

Copy file name to clipboardExpand all lines: src/node_messaging.cc
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1357,7 +1357,7 @@ std::unique_ptr<TransferData> JSTransferable::TransferOrClone() const {
13571357
}
13581358
Utf8Value deserialize_info_str(env()->isolate(), deserialize_info);
13591359
if (*deserialize_info_str == nullptr) return {};
1360-
return std::make_unique<Data>(*deserialize_info_str,
1360+
return std::make_unique<Data>(deserialize_info_str.ToString(),
13611361
Global<Value>(env()->isolate(), data));
13621362
}
13631363

Collapse file

‎src/quic/defs.h‎

Copy file name to clipboardExpand all lines: src/quic/defs.h
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ bool SetOption(Environment* env,
3939
if (!object->Get(env->context(), name).ToLocal(&value)) return false;
4040
if (!value->IsUndefined()) {
4141
Utf8Value utf8(env->isolate(), value);
42-
options->*member = *utf8;
42+
options->*member = utf8.ToString();
4343
}
4444
return true;
4545
}

0 commit comments

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