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).
This commit is contained in:
Joel Martin 2010-06-09 15:40:46 -05:00
parent 29cb15f9ca
commit 0664669ce9
1 changed files with 5 additions and 7 deletions

12
vnc.js
View File

@ -902,11 +902,6 @@ display_tight_png: function() {
//console.log(" png, RQ.length: " + RQ.length + ", clength[0]: " + clength[0] + ", clength[1]: " + clength[1]); //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 RQ.shiftBytes(1 + clength[0]); // shift off ctl + compact length
img = new Image(); 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 + "," + img.src = "data:image/" + cmode + "," +
RFB.extract_data_uri(RQ.shiftBytes(clength[1])); RFB.extract_data_uri(RQ.shiftBytes(clength[1]));
img.onload = (function () { img.onload = (function () {
@ -922,8 +917,11 @@ display_tight_png: function() {
}, },
extract_data_uri : function (arr) { extract_data_uri : function (arr) {
return escape(arr.map(function (num) { var i, stra = [];
return String.fromCharCode(num); } ).join('') ); for (i=0; i< arr.length; i++) {
stra.push(String.fromCharCode(arr[i]));
}
return escape(stra.join(''));
}, },