Movatterモバイル変換


[0]ホーム

URL:


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

Sign up
Appearance settings

Commit7fc45f5

Browse files
anonrigmarco-ippolito
authored andcommitted
url: reduce unnecessary string copies
PR-URL:#53628Reviewed-By: Richard Lau <rlau@redhat.com>Reviewed-By: Daniel Lemire <daniel@lemire.me>Reviewed-By: Luigi Pinca <luigipinca@gmail.com>Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com>Reviewed-By: Marco Ippolito <marcoippolito54@gmail.com>Reviewed-By: James M Snell <jasnell@gmail.com>
1 parente71aa7e commit7fc45f5

File tree

1 file changed

+10
-10
lines changed

1 file changed

+10
-10
lines changed

‎src/node_url.cc

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -75,20 +75,20 @@ void BindingData::Deserialize(v8::Local<v8::Context> context,
7575

7676
voidBindingData::DomainToASCII(const FunctionCallbackInfo<Value>& args) {
7777
Environment* env =Environment::GetCurrent(args);
78-
CHECK_GE(args.Length(),1);
78+
CHECK_GE(args.Length(),1);// input
7979
CHECK(args[0]->IsString());
8080

81-
std::string input =Utf8Value(env->isolate(), args[0]).ToString();
82-
if (input.empty()) {
83-
return args.GetReturnValue().Set(String::Empty(env->isolate()));
81+
Utf8Valueinput(env->isolate(), args[0]);
82+
if (input.ToStringView().empty()) {
83+
return args.GetReturnValue().SetEmptyString();
8484
}
8585

8686
// It is important to have an initial value that contains a special scheme.
8787
// Since it will change the implementation of `set_hostname` according to URL
8888
// spec.
8989
auto out = ada::parse<ada::url>("ws://x");
9090
DCHECK(out);
91-
if (!out->set_hostname(input)) {
91+
if (!out->set_hostname(input.ToStringView())) {
9292
return args.GetReturnValue().Set(String::Empty(env->isolate()));
9393
}
9494
std::string host = out->get_hostname();
@@ -98,20 +98,20 @@ void BindingData::DomainToASCII(const FunctionCallbackInfo<Value>& args) {
9898

9999
voidBindingData::DomainToUnicode(const FunctionCallbackInfo<Value>& args) {
100100
Environment* env =Environment::GetCurrent(args);
101-
CHECK_GE(args.Length(),1);
101+
CHECK_GE(args.Length(),1);// input
102102
CHECK(args[0]->IsString());
103103

104-
std::string input =Utf8Value(env->isolate(), args[0]).ToString();
105-
if (input.empty()) {
106-
return args.GetReturnValue().Set(String::Empty(env->isolate()));
104+
Utf8Valueinput(env->isolate(), args[0]);
105+
if (input.ToStringView().empty()) {
106+
return args.GetReturnValue().SetEmptyString();
107107
}
108108

109109
// It is important to have an initial value that contains a special scheme.
110110
// Since it will change the implementation of `set_hostname` according to URL
111111
// spec.
112112
auto out = ada::parse<ada::url>("ws://x");
113113
DCHECK(out);
114-
if (!out->set_hostname(input)) {
114+
if (!out->set_hostname(input.ToStringView())) {
115115
return args.GetReturnValue().Set(String::Empty(env->isolate()));
116116
}
117117
std::string result =ada::unicode::to_unicode(out->get_hostname());

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp