Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/nodejs/node.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJames M Snell <jasnell@gmail.com>2016-06-08 18:18:26 +0300
committerJames M Snell <jasnell@gmail.com>2016-06-21 20:03:08 +0300
commit6be73feaeb31dbcc1547da648341c0b6f0d2d2bb (patch)
treea03e867b1d8f25af8183bd2741765c45d9a8db2b /lib/tls.js
parent58a241d53790aee5dd6327543fc9849bd21fb9a7 (diff)
crypto,tls: perf improvements for crypto and tls getCiphers
Improve performance of crypto.getCiphers, getHashes, getCurves and tls.getCiphers by consolidating filterDuplicates logic, adding caching of output, and streamlining filterDuplicates implementation. Benchmarks: crypto.getCiphers n=1 v6.2.1 = 2559.3, new = 15890 ...... -83.89% crypto.getCiphers n=5000 v6.2.1 = 3516.3, new = 24203000 ... -99.99% tls.getCiphers n=1 v6.2.1 = 3405.3, new = 14877 ...... -77.11% tls.getCiphers n=5000 v6.2.1 = 6074.4, new = 24202000 ... -99.97% PR-URL: https://github.com/nodejs/node/pull/7225 Reviewed-By: Fedor Indutny <fedor.indutny@gmail.com> Reviewed-By: Brian White <mscdex@mscdex.net>
Diffstat (limited to 'lib/tls.js')
-rw-r--r--lib/tls.js16
1 files changed, 5 insertions, 11 deletions
diff --git a/lib/tls.js b/lib/tls.js
index 80ea0d76977..695edd8c5a6 100644
--- a/lib/tls.js
+++ b/lib/tls.js
@@ -1,6 +1,7 @@
'use strict';
-require('internal/util').assertCrypto(exports);
+const internalUtil = require('internal/util');
+internalUtil.assertCrypto(exports);
const net = require('net');
const url = require('url');
@@ -21,16 +22,9 @@ exports.DEFAULT_CIPHERS =
exports.DEFAULT_ECDH_CURVE = 'prime256v1';
-exports.getCiphers = function() {
- const names = binding.getSSLCiphers();
- // Drop all-caps names in favor of their lowercase aliases,
- var ctx = {};
- names.forEach(function(name) {
- if (/^[0-9A-Z\-]+$/.test(name)) name = name.toLowerCase();
- ctx[name] = true;
- });
- return Object.getOwnPropertyNames(ctx).sort();
-};
+exports.getCiphers = internalUtil.cachedResult(() => {
+ return internalUtil.filterDuplicateStrings(binding.getSSLCiphers(), true);
+});
// Convert protocols array into valid OpenSSL protocols list
// ("\x06spdy/2\x08http/1.1\x08http/1.0")