Work around a Safari JIT bug.
authorJoe Wreschnig <joe.wreschnig@gmail.com>
Tue, 23 Sep 2014 12:15:03 +0000 (14:15 +0200)
committerJoe Wreschnig <joe.wreschnig@gmail.com>
Tue, 23 Sep 2014 12:15:03 +0000 (14:15 +0200)
src/yuu/yf.js

index 5df966debff5de7ff9e3584c0e5b847101d6d06b..3ea8b208802a113342bb25256fd0725645831831 100644 (file)
         case 1: return function () { return f.call(this, arguments); };
         default:
             return function () {
-                arguments[length - 1] = slice(arguments, length - 1);
-                return f.apply(this, arguments);
+                /* The following code can do this without creating a
+                   new array, but it causes function calls to randomly
+                   not happen in Safari (Mobile and OS X) - presumably
+                   due to some JIT bug, because surrounding it in
+                   an empty try/catch block also makes it work.
+                   
+                   arguments[length - 1] = slice(arguments, length - 1);
+                */
+                var args = slice(arguments, 0, length - 1);
+                args.push(slice(arguments, length - 1));
+                return f.apply(this, args);
             };
         }
     }