GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — src: avoid strcmp() with Utf8Value · nodejs/node@4bc17fd

File tree

Expand file treeCollapse file tree
Open diff view settings
Filter options
  • src
    • crypto
      • crypto_context.cc
      • crypto_tls.cc
    • node_report.cc
    • util.h
Expand file treeCollapse file tree
Open diff view settings
Collapse file

‎src/crypto/crypto_context.cc‎

Copy file name to clipboardExpand all lines: src/crypto/crypto_context.cc
+1-2Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -840,8 +840,7 @@ void SecureContext::SetECDHCurve(const FunctionCallbackInfo<Value>& args) {
840840

841841
Utf8Value curve(env->isolate(), args[0]);
842842

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)) {
845844
return THROW_ERR_CRYPTO_OPERATION_FAILED(env, "Failed to set ECDH curve");
846845
}
847846
}
Collapse file

‎src/crypto/crypto_tls.cc‎

Copy file name to clipboardExpand all lines: src/crypto/crypto_tls.cc
+1-2Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1350,8 +1350,7 @@ unsigned int TLSWrap::PskServerCallback(
13501350

13511351
// Make sure there are no utf8 replacement symbols.
13521352
Utf8Value identity_utf8(env->isolate(), identity_str);
1353-
if (strcmp(*identity_utf8, identity) != 0)
1354-
return 0;
1353+
if (identity_utf8 != identity) return 0;
13551354

13561355
Local<Value> argv[] = {
13571356
identity_str,
Collapse file

‎src/node_report.cc‎

Copy file name to clipboardExpand all lines: src/node_report.cc
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -401,7 +401,7 @@ static void PrintJavaScriptErrorProperties(JSONWriter* writer,
401401
continue;
402402
}
403403
node::Utf8Value k(isolate, key);
404-
if (!strcmp(*k, "stack") || !strcmp(*k, "message")) continue;
404+
if (k == "stack" || k == "message") continue;
405405
node::Utf8Value v(isolate, value_string);
406406
writer->json_keyvalue(k.ToStringView(), v.ToStringView());
407407
}
Collapse file

‎src/util.h‎

Copy file name to clipboardExpand all lines: src/util.h
+2-3Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -531,9 +531,8 @@ class Utf8Value : public MaybeStackBuffer<char> {
531531
return std::string_view(out(), length());
532532
}
533533

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); }
537536
};
538537

539538
class TwoByteValue : public MaybeStackBuffer<uint16_t> {

0 commit comments

Comments
0 (0)
You are visitor 01402503 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.