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 eb99eec

Browse filesBrowse files
addaleaxtargos
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 c1f1dbd commit eb99eec
Copy full SHA for eb99eec

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
@@ -442,11 +442,9 @@ void Blob::StoreDataObject(const FunctionCallbackInfo<Value>& args) {
442442
Utf8Value type(isolate, args[3]);
443443

444444
binding_data->store_data_object(
445-
std::string(*key, key.length()),
445+
key.ToString(),
446446
BlobBindingData::StoredDataObject(
447-
BaseObjectPtr<Blob>(blob),
448-
length,
449-
std::string(*type, type.length())));
447+
BaseObjectPtr<Blob>(blob), length, type.ToString()));
450448
}
451449

452450
// Note: applying the V8 Fast API to the following function does not produce
@@ -486,7 +484,7 @@ void Blob::GetDataObject(const FunctionCallbackInfo<Value>& args) {
486484
Utf8Value key(isolate, args[0]);
487485

488486
BlobBindingData::StoredDataObject stored =
489-
binding_data->get_data_object(std::string(*key, key.length()));
487+
binding_data->get_data_object(key.ToString());
490488
if (stored.blob) {
491489
Local<Value> type;
492490
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
@@ -284,10 +284,10 @@ ContextifyContext* ContextifyContext::New(Local<Context> v8_context,
284284
options->allow_code_gen_wasm);
285285

286286
Utf8Value name_val(env->isolate(), options->name);
287-
ContextInfo info(*name_val);
287+
ContextInfo info(name_val.ToString());
288288
if (!options->origin.IsEmpty()) {
289289
Utf8Value origin_val(env->isolate(), options->origin);
290-
info.origin = *origin_val;
290+
info.origin = origin_val.ToString();
291291
}
292292

293293
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
@@ -276,12 +276,12 @@ inline void THROW_ERR_REQUIRE_ASYNC_MODULE(
276276
if (!parent_filename.IsEmpty() && parent_filename->IsString()) {
277277
Utf8Value utf8(env->isolate(), parent_filename);
278278
message += "\n From ";
279-
message += utf8.out();
279+
message += utf8.ToStringView();
280280
}
281281
if (!filename.IsEmpty() && filename->IsString()) {
282282
Utf8Value utf8(env->isolate(), filename);
283283
message += "\n Requiring ";
284-
message += +utf8.out();
284+
message += utf8.ToStringView();
285285
}
286286
THROW_ERR_REQUIRE_ASYNC_MODULE(env, message.c_str());
287287
}
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
@@ -1368,7 +1368,7 @@ std::unique_ptr<TransferData> JSTransferable::TransferOrClone() const {
13681368
}
13691369
Utf8Value deserialize_info_str(env()->isolate(), deserialize_info);
13701370
if (*deserialize_info_str == nullptr) return {};
1371-
return std::make_unique<Data>(*deserialize_info_str,
1371+
return std::make_unique<Data>(deserialize_info_str.ToString(),
13721372
Global<Value>(env()->isolate(), data));
13731373
}
13741374

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.