src: deduplicate `SetALPN` implementations · nodejs/node@17cb272 · GitHub
Skip to content

Commit 17cb272

Browse files
tniessendanielleadams
authored andcommitted
src: deduplicate SetALPN implementations
Instead of accepting either a std::string or a mysterious Local<Value>, accept any std::string_view, which can trivially be constructed from both strings and ArrayBufferViews. This also removes the need to check IsArrayBufferView() inside of SetALPN, which was dead code anyway. PR-URL: #43756 Reviewed-By: Darshan Sen <raisinten@gmail.com> Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Joyee Cheung <joyeec9h3@gmail.com>
1 parent b4c75a9 commit 17cb272

3 files changed

Lines changed: 8 additions & 17 deletions

File tree

src/crypto/crypto_common.cc

Lines changed: 4 additions & 13 deletions

src/crypto/crypto_common.h

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -33,9 +33,8 @@ void LogSecret(
3333
const unsigned char* secret,
3434
size_t secretlen);
3535

36-
bool SetALPN(const SSLPointer& ssl, const std::string& alpn);
37-
38-
bool SetALPN(const SSLPointer& ssl, v8::Local<v8::Value> alpn);
36+
// TODO(tniessen): use std::u8string_view when we switch to C++20.
37+
bool SetALPN(const SSLPointer& ssl, std::string_view alpn);
3938

4039
v8::MaybeLocal<v8::Value> GetSSLOCSPResponse(
4140
Environment* env,

src/crypto/crypto_tls.cc

Lines changed: 2 additions & 1 deletion

0 commit comments

Comments
 (0)