From 6716271477db4cb01ff60586471a5ec9a99fc37c Mon Sep 17 00:00:00 2001 From: Ivan Zahariev Date: Tue, 18 Oct 2016 11:42:01 +0300 Subject: [PATCH] Due to a bug in node.js 4.3, we need to declare and init on separate lines, or else node.js performs about four times slower. See: https://blog.famzah.net/2016/09/10/cpp-vs-python-vs-php-vs-java-vs-others-performance-benchmark-2016-q3/#comment-21872 --- primes.js | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/primes.js b/primes.js index 745673c..da10091 100644 --- a/primes.js +++ b/primes.js @@ -25,7 +25,11 @@ function get_primes7(n) { m = 2*i + 3; } - var res = [2]; + // due to a bug in node.js 4.3, we need to declare and init on separate lines + // or else node.js performs about four times slower + var res = []; + res.push(2); + for (var x = 0; x < s.length; x++) { if (s[x]) { res.push(s[x]);