]> git.parisson.com Git - pdf.js.git/commitdiff
Switch to push instead of slice. Faster on jsperf, but doesn't seem to be faster...
authorBrendan Dahl <brendan.dahl@gmail.com>
Fri, 30 Dec 2011 22:59:00 +0000 (14:59 -0800)
committerBrendan Dahl <brendan.dahl@gmail.com>
Fri, 30 Dec 2011 22:59:00 +0000 (14:59 -0800)
src/function.js

index 996b62c6a9903d4070660d4a7261c80a8008fef2..83db53ba171b638aa24bc091cc6c56b509a66784 100644 (file)
@@ -437,8 +437,9 @@ var PostScriptStack = (function PostScriptStackClosure() {
     copy: function copy(n) {
       if (this.stack.length + n >= MAX_STACK_SIZE)
         error('PostScript function stack overflow.');
-      var part = this.stack.slice(this.stack.length - n);
-      this.stack = this.stack.concat(part);
+      var stack = this.stack;
+      for (var i = stack.length - n, j = n - 1; j >= 0; j--, i++)
+        stack.push(stack[i]);
     },
     index: function index(n) {
       this.push(this.stack[this.stack.length - n - 1]);