{"ScriptPreparationCode":"function defaultEqualityCheck(a, b) {\r\n return a === b\r\n}\r\n\r\nfunction defaultMemoize_original(func, equalityCheck = defaultEqualityCheck) {\r\n let lastArgs = null\r\n let lastResult = null\r\n return (...args) =\u003E {\r\n if (\r\n lastArgs === null ||\r\n lastArgs.length !== args.length ||\r\n !args.every((value, index) =\u003E equalityCheck(value, lastArgs[index]))\r\n ) {\r\n lastResult = func(...args)\r\n }\r\n lastArgs = args\r\n return lastResult\r\n }\r\n}\r\n\r\nfunction defaultMemoize_optimized(func, equalityCheck = defaultEqualityCheck) {\r\n const isEqual = (value, index) =\u003E equalityCheck(value, lastArgs[index])\r\n let lastArgs = null\r\n let lastResult = null\r\n return (...args) =\u003E {\r\n if (\r\n lastArgs === null ||\r\n lastArgs.length !== args.length ||\r\n !args.every(isEqual)\r\n ) {\r\n lastResult = func(...args)\r\n }\r\n lastArgs = args\r\n return lastResult\r\n }\r\n}\r\n\r\nfunction combine(a, b) {\r\n return { combined: a \u002B b };\r\n}\r\n\r\nvar combine_original = defaultMemoize_original(combine);\r\nvar combine_optimized = defaultMemoize_optimized(combine);\r\n\r\nvar NUM_REPEAT = 50000;","TestCases":[{"Name":"Original defaultMemoize","Code":"let result1 = 0;\r\nfor (let i = 0; i \u003C NUM_REPEAT; \u002B\u002Bi) \r\n result1 \u002B= combine_original(1, 2).combined;","IsDeferred":false},{"Name":"Optimized defaultMemoize","Code":"let result2 = 0;\r\nfor (let i = 0; i \u003C NUM_REPEAT; \u002B\u002Bi) \r\n result2 \u002B= combine_optimized(1, 2).combined;","IsDeferred":false},{"Name":"No memoization","Code":"let result3 = 0;\r\nfor (let i = 0; i \u003C NUM_REPEAT; \u002B\u002Bi) \r\n result3 \u002B= combine(1, 2).combined;","IsDeferred":false}]}