From 0664669ce9db012fe8e86e8ea2a0aae3604e9500 Mon Sep 17 00:00:00 2001 From: Joel Martin Date: Wed, 9 Jun 2010 15:40:46 -0500 Subject: [PATCH] Almost double firefox tight_png render performance. When extracting the data URI info, much more efficient in firefox to iterate and push onto an array, then to generate the whole array at once using the map function. Chrome is mostly unaffected by this change (might be slightly better). --- vnc.js | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/vnc.js b/vnc.js index 12e8c257..e1dc0ef6 100644 --- a/vnc.js +++ b/vnc.js @@ -902,11 +902,6 @@ display_tight_png: function() { //console.log(" png, RQ.length: " + RQ.length + ", clength[0]: " + clength[0] + ", clength[1]: " + clength[1]); RQ.shiftBytes(1 + clength[0]); // shift off ctl + compact length img = new Image(); - /* - strdata = RQ.shiftBytes(clength[1]).map(function (num) { - return String.fromCharCode(num); } ).join(''); - img.src = "data:image/" + cmode + "," + escape(strdata); - */ img.src = "data:image/" + cmode + "," + RFB.extract_data_uri(RQ.shiftBytes(clength[1])); img.onload = (function () { @@ -922,8 +917,11 @@ display_tight_png: function() { }, extract_data_uri : function (arr) { - return escape(arr.map(function (num) { - return String.fromCharCode(num); } ).join('') ); + var i, stra = []; + for (i=0; i< arr.length; i++) { + stra.push(String.fromCharCode(arr[i])); + } + return escape(stra.join('')); },