{"ScriptPreparationCode":"function getCookieIX_B(name, str,idx) {\r\n name = \u0022; \u0022 \u002B name \u002B \u0022=\u0022;\r\n var ck = str || document.cookie;\r\n ck = \u0022; \u0022 \u002B ck;\r\n if ((idx = ck.lastIndexOf(name)) == -1) {\r\n return undefined;\r\n }\r\n var nameLength = name.length;\r\n var p1 = ck.substring(idx \u002B nameLength);\r\n var idx2 = p1.indexOf(\u0022;\u0022);\r\n idx2 = idx2==-1 ? undefined : idx2;\r\n var p2 = p1.substring(0, idx2);\r\n return decodeURIComponent(p2);\r\n}\r\nfunction getCookieIX(name,str){\r\n name = name\u002B\u0027=\u0027;\r\n var ck = str || document.cookie;\r\n var idx = ck.lastIndexOf(name);\r\n if(idx==-1){ return undefined}\r\n var nameLength = name.length;\r\n var p1 = ck.substring(idx\u002BnameLength);\r\n var idx2 = p1.indexOf(\u0027;\u0027);\r\n if(idx2\u003E-1){\r\n p1 = p1.substring(0,idx2);\r\n }\r\n return decodeURIComponent(p1);\r\n}\r\n\r\nfunction getCookieIX2(name, str,idx) {\r\n name = \u0022; \u0022 \u002B name \u002B \u0022=\u0022;\r\n var ck = str || document.cookie;\r\n ck = \u0022; \u0022 \u002B ck;\r\n if ((idx = ck.lastIndexOf(name)) == -1) {\r\n return undefined;\r\n }\r\n var nameLength = name.length;\r\n var p1 = ck.substring(idx \u002B nameLength);\r\n p1 = p1.split(\u0027;\u0027)[0];\r\n return decodeURIComponent(p1);\r\n}\r\n\r\nfunction getCookie(name,str) {\r\n var nameEQ = name \u002B \u0022=\u0022;\r\n var ca = (str||document.cookie).split(\u0022;\u0022);\r\n for (var i = 0; i \u003C ca.length; i\u002B\u002B) {\r\n var c = ca[i];\r\n while (c.charAt(0) == \u0022 \u0022) c = c.substring(1, c.length);\r\n if (c.indexOf(nameEQ) == 0) {\r\n var d = c.substring(nameEQ.length, c.length);\r\n d = decodeURIComponent(d);\r\n return d;\r\n }\r\n }\r\n return undefined;\r\n}\r\n\r\nfunction getCookieM(name,str) {\r\n name = name \u002B \u0022\u0022;\r\n var re = new RegExp(\u0022(^| )\u0022 \u002B name \u002B \u0022=([^;]\u002B)\u0022, \u0022gmi\u0022);\r\n var m = (str||document.cookie).match(re);\r\n if (!!m) {\r\n m = m.pop();\r\n m = m.substring(m.indexOf(\u0022=\u0022) \u002B 1);\r\n m = !!m ? decodeURIComponent(m) : m;\r\n return m;\r\n }\r\n}\r\n\r\nfunction getCookieW(name, str) {\r\n var str = str || document.cookie;\r\n var re = new RegExp(\u0022(?:^|; )(\u0022\u002Bname\u002B\u0022\u002B?)(?:=([^;]*))?(?:;|$)\u0022, \u0022gi\u0022);\r\n var value;\r\n var match;\r\n while ((match = re.exec(str))) {\r\n re.lastIndex = match.index \u002B match.length - 1;\r\n var k = match[1];\r\n var v = decodeURIComponent(match[2]);\r\n !!v \u0026\u0026 (value = v);\r\n }\r\n\r\n return value;\r\n}\r\n\r\nfunction getCookieR(name,str) {\r\n var nameEQ = name \u002B \u0022=\u0022;\r\n var ca = (str||document.cookie).split(\u0022;\u0022);\r\n var cal = ca.length;\r\n for (var i = cal; i \u003E= 0; i--) {\r\n var c = ca[i];\r\n if (!!c) {\r\n c = c.trim();\r\n if (c.indexOf(nameEQ) == 0) {\r\n var d = c.substring(nameEQ.length, c.length);\r\n d = decodeURIComponent(d);\r\n return d;\r\n }\r\n }\r\n }\r\n return undefined;\r\n}\r\nfunction generateTestData(){\r\n let foo = [];\r\n for (let i = 0; i \u003C 20; i\u002B\u002B) {\r\n var x = i\u002B1;\r\n foo.push(\u0027foo_\u0027\u002Bx\u002B\u0027=\u0027\u002B\u0027bar_\u0027\u002Bx\u002B\u0027_\u0027\u002Bperformance.now());\r\n foo.push(\u0027foo_\u0027\u002Bx\u002B\u0027=\u0027\u002B\u0027bar_second_\u0027\u002Bx\u002B\u0027_\u0027\u002Bperformance.now());\r\n }\r\n foo = foo.join(\u0027; \u0027);\r\n return foo;\r\n}\r\nvar hay = generateTestData();\r\n","TestCases":[{"Name":"Regex loop","Code":"getCookieW(\u0027foo_10\u0027,hay)","IsDeferred":false},{"Name":"Regex","Code":"getCookieM(\u0027foo_10\u0027,hay)","IsDeferred":false},{"Name":"Original","Code":"getCookie(\u0027foo_10\u0027,hay)","IsDeferred":false},{"Name":"Original reversed","Code":"getCookieR(\u0027foo_10\u0027,hay)","IsDeferred":false},{"Name":"LastIndexOf","Code":"getCookieIX(\u0027foo_10\u0027,hay)","IsDeferred":false},{"Name":"LastIndexOf B","Code":"getCookieIX_B(\u0027foo_10\u0027,hay)","IsDeferred":false},{"Name":"LastIndexOf 2","Code":"getCookieIX2(\u0027foo_10\u0027,hay)","IsDeferred":false}]}