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.
1 /* The Great Computer Language Shootout
2 http://shootout.alioth.debian.org/
3 contributed by Isaac Gouy */
5 function TreeNode(left,right,item){
6 this.left = left;
7 this.right = right;
8 this.item = item;
9 }
11 TreeNode.prototype.itemCheck = function(){
12 if (this.left==null) return this.item;
13 else return this.item + this.left.itemCheck() - this.right.itemCheck();
14 }
16 function bottomUpTree(item,depth){
17 if (depth>0){
18 return new TreeNode(
19 bottomUpTree(2*item-1, depth-1)
20 ,bottomUpTree(2*item, depth-1)
21 ,item
22 );
23 }
24 else {
25 return new TreeNode(null,null,item);
26 }
27 }
29 var ret;
31 /* BEGIN LOOP */
32 for ( var n = 4; n <= 7; n += 1 ) {
33 var minDepth = 4;
34 var maxDepth = Math.max(minDepth + 2, n);
35 var stretchDepth = maxDepth + 1;
37 var check = bottomUpTree(0,stretchDepth).itemCheck();
39 var longLivedTree = bottomUpTree(0,maxDepth);
40 /* BEGIN LOOP */
41 for (var depth=minDepth; depth<=maxDepth; depth+=2){
42 var iterations = 1 << (maxDepth - depth + minDepth);
44 check = 0;
45 /* BEGIN LOOP */
46 for (var i=1; i<=iterations; i++){
47 check += bottomUpTree(i,depth).itemCheck();
48 check += bottomUpTree(-i,depth).itemCheck();
49 }
50 /* END LOOP */
51 }
52 /* END LOOP */
54 ret = longLivedTree.itemCheck();
55 }
56 /* END LOOP */