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 | // Contributed by Ian Osgood |
michael@0 | 5 | |
michael@0 | 6 | function pad(n,width) { |
michael@0 | 7 | var s = n.toString(); |
michael@0 | 8 | /* BEGIN LOOP */ |
michael@0 | 9 | while (s.length < width) s = ' ' + s; |
michael@0 | 10 | /* END LOOP */ |
michael@0 | 11 | return s; |
michael@0 | 12 | } |
michael@0 | 13 | |
michael@0 | 14 | function primes(isPrime, n) { |
michael@0 | 15 | var i, count = 0, m = 10000<<n, size = m+31>>5; |
michael@0 | 16 | |
michael@0 | 17 | /* BEGIN LOOP */ |
michael@0 | 18 | for (i=0; i<size; i++) isPrime[i] = 0xffffffff; |
michael@0 | 19 | /* END LOOP */ |
michael@0 | 20 | |
michael@0 | 21 | /* BEGIN LOOP */ |
michael@0 | 22 | for (i=2; i<m; i++) |
michael@0 | 23 | if (isPrime[i>>5] & 1<<(i&31)) { |
michael@0 | 24 | /* BEGIN LOOP */ |
michael@0 | 25 | for (var j=i+i; j<m; j+=i) |
michael@0 | 26 | isPrime[j>>5] &= ~(1<<(j&31)); |
michael@0 | 27 | /* END LOOP */ |
michael@0 | 28 | count++; |
michael@0 | 29 | } |
michael@0 | 30 | /* END LOOP */ |
michael@0 | 31 | } |
michael@0 | 32 | |
michael@0 | 33 | function sieve() { |
michael@0 | 34 | /* BEGIN LOOP */ |
michael@0 | 35 | for (var i = 4; i <= 4; i++) { |
michael@0 | 36 | var isPrime = new Array((10000<<i)+31>>5); |
michael@0 | 37 | primes(isPrime, i); |
michael@0 | 38 | } |
michael@0 | 39 | /* END LOOP */ |
michael@0 | 40 | } |
michael@0 | 41 | |
michael@0 | 42 | sieve(); |