Commit 0664669c authored by Joel Martin's avatar Joel Martin

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).
parent 29cb15f9
...@@ -902,11 +902,6 @@ display_tight_png: function() { ...@@ -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() { ...@@ -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(''));
}, },
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment