mirror of
https://github.com/nodejs/node.git
synced 2026-11-27 17:52:27 -05:00
src: avoid strcmp() with Utf8Value
Having Utf8Value::operator==() without operator!=() is awkward in C++17, so add the negated equality operator. Then, use either instead of strcmp() where appropriate. PR-URL: https://github.com/nodejs/node/pull/47827 Reviewed-By: Yagiz Nizipli <yagiz@nizipli.com> Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl> Reviewed-By: Mohammed Keyvanzadeh <mohammadkeyvanzade94@gmail.com> Reviewed-By: Darshan Sen <raisinten@gmail.com> Reviewed-By: Filip Skokan <panva.ip@gmail.com>
This commit is contained in:
1 parent
1625ae11fe
commit
4bc17fd67b
4 files changed
+5
-8
No files matched your search
@@ -840,8 +840,7 @@ void SecureContext::SetECDHCurve(const FunctionCallbackInfo<Value>& args) {
|
||||
|
||||
Utf8Value curve(env->isolate(), args[0]);
|
||||
|
||||
if (strcmp(*curve, "auto") != 0 &&
|
||||
!SSL_CTX_set1_curves_list(sc->ctx_.get(), *curve)) {
|
||||
if (curve != "auto" && !SSL_CTX_set1_curves_list(sc->ctx_.get(), *curve)) {
|
||||
return THROW_ERR_CRYPTO_OPERATION_FAILED(env, "Failed to set ECDH curve");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1350,8 +1350,7 @@ unsigned int TLSWrap::PskServerCallback(
|
||||
|
||||
// Make sure there are no utf8 replacement symbols.
|
||||
Utf8Value identity_utf8(env->isolate(), identity_str);
|
||||
if (strcmp(*identity_utf8, identity) != 0)
|
||||
return 0;
|
||||
if (identity_utf8 != identity) return 0;
|
||||
|
||||
Local<Value> argv[] = {
|
||||
identity_str,
|
||||
|
||||
+1
-1
@@ -401,7 +401,7 @@ static void PrintJavaScriptErrorProperties(JSONWriter* writer,
|
||||
continue;
|
||||
}
|
||||
node::Utf8Value k(isolate, key);
|
||||
if (!strcmp(*k, "stack") || !strcmp(*k, "message")) continue;
|
||||
if (k == "stack" || k == "message") continue;
|
||||
node::Utf8Value v(isolate, value_string);
|
||||
writer->json_keyvalue(k.ToStringView(), v.ToStringView());
|
||||
}
|
||||
|
||||
+2
-3
@@ -531,9 +531,8 @@ class Utf8Value : public MaybeStackBuffer<char> {
|
||||
return std::string_view(out(), length());
|
||||
}
|
||||
|
||||
inline bool operator==(const char* a) const {
|
||||
return strcmp(out(), a) == 0;
|
||||
}
|
||||
inline bool operator==(const char* a) const { return strcmp(out(), a) == 0; }
|
||||
inline bool operator!=(const char* a) const { return !(*this == a); }
|
||||
};
|
||||
|
||||
class TwoByteValue : public MaybeStackBuffer<uint16_t> {
|
||||
|
||||
Reference in new issue
Block a user