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

Appearance settings

Commit 3901c7f

Browse filesBrowse files
danbevaddaleax
authored andcommitted
src: add GetCipherValue function
This commit extracts the code that is the same in GetCipherName, GetCipherStandardName, and GetCipherVersion into function named GetCipherValue. The motivation for this change is to improve readabilty by removing the duplicated code. PR-URL: #34287 Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl> Reviewed-By: Tobias Nießen <tniessen@tnie.de> Reviewed-By: James M Snell <jasnell@gmail.com>
1 parent 513ad14 commit 3901c7f
Copy full SHA for 3901c7f

File tree

Expand file treeCollapse file tree

1 file changed

+11
-15
lines changed
Open diff view settings
Filter options
Expand file treeCollapse file tree

1 file changed

+11
-15
lines changed
Open diff view settings
Collapse file

‎src/node_crypto_common.cc‎

Copy file name to clipboardExpand all lines: src/node_crypto_common.cc
+11-15Lines changed: 11 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -385,31 +385,27 @@ Local<Value> ToV8Value(Environment* env, const BIOPointer& bio) {
385385
return ret.FromMaybe(Local<Value>());
386386
}
387387

388-
MaybeLocal<Value> GetCipherName(
389-
Environment* env,
390-
const SSL_CIPHER* cipher) {
388+
MaybeLocal<Value> GetCipherValue(Environment* env,
389+
const SSL_CIPHER* cipher,
390+
const char* (*getstr)(const SSL_CIPHER* cipher)) {
391391
if (cipher == nullptr)
392392
return Undefined(env->isolate());
393393

394-
return OneByteString(env->isolate(), SSL_CIPHER_get_name(cipher));
394+
return OneByteString(env->isolate(), getstr(cipher));
395395
}
396396

397-
MaybeLocal<Value> GetCipherStandardName(
398-
Environment* env,
399-
const SSL_CIPHER* cipher) {
400-
if (cipher == nullptr)
401-
return Undefined(env->isolate());
402-
403-
return OneByteString(env->isolate(), SSL_CIPHER_standard_name(cipher));
397+
MaybeLocal<Value> GetCipherName(Environment* env, const SSL_CIPHER* cipher) {
398+
return GetCipherValue(env, cipher, SSL_CIPHER_get_name);
404399
}
405400

406-
MaybeLocal<Value> GetCipherVersion(
401+
MaybeLocal<Value> GetCipherStandardName(
407402
Environment* env,
408403
const SSL_CIPHER* cipher) {
409-
if (cipher == nullptr)
410-
return Undefined(env->isolate());
404+
return GetCipherValue(env, cipher, SSL_CIPHER_standard_name);
405+
}
411406

412-
return OneByteString(env->isolate(), SSL_CIPHER_get_version(cipher));
407+
MaybeLocal<Value> GetCipherVersion(Environment* env, const SSL_CIPHER* cipher) {
408+
return GetCipherValue(env, cipher, SSL_CIPHER_get_version);
413409
}
414410

415411
StackOfX509 CloneSSLCerts(X509Pointer&& cert,

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.