GeezerVison is showing github.com — src: avoid strcmp() with Utf8Value · nodejs/node@4bc17fd
File tree
Expand file treeCollapse file tree
Open diff view settings
Expand file treeCollapse file tree
Open diff view settings
Collapse file
Copy file name to clipboardExpand all lines: src/crypto/crypto_context.cc +1-2Lines changed: 1 addition & 2 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -840,8 +840,7 @@ void SecureContext::SetECDHCurve(const FunctionCallbackInfo<Value>& args) { |
840 | 840 |
|
841 | 841 | Utf8Value curve(env->isolate(), args[0]); |
842 | 842 |
|
843 | | - if (strcmp(*curve, "auto") != 0 && |
844 | | - !SSL_CTX_set1_curves_list(sc->ctx_.get(), *curve)) { |
| 843 | + if (curve != "auto" && !SSL_CTX_set1_curves_list(sc->ctx_.get(), *curve)) { |
845 | 844 | return THROW_ERR_CRYPTO_OPERATION_FAILED(env, "Failed to set ECDH curve"); |
846 | 845 | } |
847 | 846 | } |
|
Collapse file
Copy file name to clipboardExpand all lines: src/crypto/crypto_tls.cc +1-2Lines changed: 1 addition & 2 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -1350,8 +1350,7 @@ unsigned int TLSWrap::PskServerCallback( |
1350 | 1350 |
|
1351 | 1351 | // Make sure there are no utf8 replacement symbols. |
1352 | 1352 | Utf8Value identity_utf8(env->isolate(), identity_str); |
1353 | | - if (strcmp(*identity_utf8, identity) != 0) |
1354 | | - return 0; |
| 1353 | + if (identity_utf8 != identity) return 0; |
1355 | 1354 |
|
1356 | 1355 | Local<Value> argv[] = { |
1357 | 1356 | identity_str, |
|
Collapse file
Copy file name to clipboardExpand all lines: src/node_report.cc +1-1Lines changed: 1 addition & 1 deletion | Original file line number | Diff line number | Diff line change |
|---|
@@ -401,7 +401,7 @@ static void PrintJavaScriptErrorProperties(JSONWriter* writer, |
401 | 401 | continue; |
402 | 402 | } |
403 | 403 | node::Utf8Value k(isolate, key); |
404 | | - if (!strcmp(*k, "stack") || !strcmp(*k, "message")) continue; |
| 404 | + if (k == "stack" || k == "message") continue; |
405 | 405 | node::Utf8Value v(isolate, value_string); |
406 | 406 | writer->json_keyvalue(k.ToStringView(), v.ToStringView()); |
407 | 407 | } |
|
Collapse file
Copy file name to clipboardExpand all lines: src/util.h +2-3Lines changed: 2 additions & 3 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -531,9 +531,8 @@ class Utf8Value : public MaybeStackBuffer<char> { |
531 | 531 | return std::string_view(out(), length()); |
532 | 532 | } |
533 | 533 |
|
534 | | - inline bool operator==(const char* a) const { |
535 | | - return strcmp(out(), a) == 0; |
536 | | - } |
| 534 | + inline bool operator==(const char* a) const { return strcmp(out(), a) == 0; } |
| 535 | + inline bool operator!=(const char* a) const { return !(*this == a); } |
537 | 536 | }; |
538 | 537 |
|
539 | 538 | class TwoByteValue : public MaybeStackBuffer<uint16_t> { |
|