Sat, 03 Jan 2015 20:18:00 +0100
Conditionally enable double key logic according to:
private browsing mode or privacy.thirdparty.isolate preference and
implement in GetCookieStringCommon and FindCookie where it counts...
With some reservations of how to convince FindCookie users to test
condition and pass a nullptr when disabling double key logic.
michael@0 | 1 | // The Great Computer Language Shootout |
michael@0 | 2 | // http://shootout.alioth.debian.org/ |
michael@0 | 3 | // |
michael@0 | 4 | // modified by Isaac Gouy |
michael@0 | 5 | |
michael@0 | 6 | function pad(number,width){ |
michael@0 | 7 | var s = number.toString(); |
michael@0 | 8 | var prefixWidth = width - s.length; |
michael@0 | 9 | if (prefixWidth>0){ |
michael@0 | 10 | /* BEGIN LOOP */ |
michael@0 | 11 | for (var i=1; i<=prefixWidth; i++) s = " " + s; |
michael@0 | 12 | /* END LOOP */ |
michael@0 | 13 | } |
michael@0 | 14 | return s; |
michael@0 | 15 | } |
michael@0 | 16 | |
michael@0 | 17 | function nsieve(m, isPrime){ |
michael@0 | 18 | var i, k, count; |
michael@0 | 19 | |
michael@0 | 20 | /* BEGIN LOOP */ |
michael@0 | 21 | for (i=2; i<=m; i++) { isPrime[i] = true; } |
michael@0 | 22 | /* END LOOP */ |
michael@0 | 23 | count = 0; |
michael@0 | 24 | |
michael@0 | 25 | /* BEGIN LOOP */ |
michael@0 | 26 | for (i=2; i<=m; i++){ |
michael@0 | 27 | if (isPrime[i]) { |
michael@0 | 28 | /* BEGIN LOOP */ |
michael@0 | 29 | for (k=i+i; k<=m; k+=i) isPrime[k] = false; |
michael@0 | 30 | /* END LOOP */ |
michael@0 | 31 | count++; |
michael@0 | 32 | } |
michael@0 | 33 | } |
michael@0 | 34 | /* END LOOP */ |
michael@0 | 35 | return count; |
michael@0 | 36 | } |
michael@0 | 37 | |
michael@0 | 38 | function sieve() { |
michael@0 | 39 | /* BEGIN LOOP */ |
michael@0 | 40 | for (var i = 1; i <= 3; i++ ) { |
michael@0 | 41 | var m = (1<<i)*10000; |
michael@0 | 42 | var flags = Array(m+1); |
michael@0 | 43 | nsieve(m, flags); |
michael@0 | 44 | } |
michael@0 | 45 | /* END LOOP */ |
michael@0 | 46 | } |
michael@0 | 47 | |
michael@0 | 48 | sieve(); |