js/src/devtools/jint/sunspider/bitops-nsieve-bits.js

Sat, 03 Jan 2015 20:18:00 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Sat, 03 Jan 2015 20:18:00 +0100
branch
TOR_BUG_3246
changeset 7
129ffea94266
permissions
-rw-r--r--

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.

     1 // The Great Computer Language Shootout
     2 //  http://shootout.alioth.debian.org
     3 //
     4 //  Contributed by Ian Osgood
     6 function pad(n,width) {
     7   var s = n.toString();
     8   /* BEGIN LOOP */
     9   while (s.length < width) s = ' ' + s;
    10   /* END LOOP */
    11   return s;
    12 }
    14 function primes(isPrime, n) {
    15   var i, count = 0, m = 10000<<n, size = m+31>>5;
    17   /* BEGIN LOOP */
    18   for (i=0; i<size; i++) isPrime[i] = 0xffffffff;
    19   /* END LOOP */
    21   /* BEGIN LOOP */
    22   for (i=2; i<m; i++)
    23     if (isPrime[i>>5] & 1<<(i&31)) {
    24       /* BEGIN LOOP */
    25       for (var j=i+i; j<m; j+=i)
    26         isPrime[j>>5] &= ~(1<<(j&31));
    27       /* END LOOP */
    28       count++;
    29     }
    30   /* END LOOP */
    31 }
    33 function sieve() {
    34     /* BEGIN LOOP */
    35     for (var i = 4; i <= 4; i++) {
    36         var isPrime = new Array((10000<<i)+31>>5);
    37         primes(isPrime, i);
    38     }
    39     /* END LOOP */
    40 }
    42 sieve();

mercurial