mirror of https://github.com/gorhill/uBlock.git
Fix redundant calls to extract image data
Related issue: - https://github.com/uBlockOrigin/uBlock-issues/issues/2243#issuecomment-1236194011
This commit is contained in:
parent
e3a0634945
commit
0c9ab84846
|
@ -703,7 +703,7 @@ vAPI.setIcon = (( ) => {
|
|||
const path = icons[i].path;
|
||||
for ( const key in path ) {
|
||||
if ( path.hasOwnProperty(key) === false ) { continue; }
|
||||
imgs.push({ i: i, p: key });
|
||||
imgs.push({ i: i, p: key, cached: false });
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -724,6 +724,7 @@ vAPI.setIcon = (( ) => {
|
|||
const ctx = document.createElement('canvas').getContext('2d');
|
||||
const iconData = [ null, null ];
|
||||
for ( const img of imgs ) {
|
||||
if ( img.cached ) { continue; }
|
||||
const w = img.r.naturalWidth, h = img.r.naturalHeight;
|
||||
ctx.width = w; ctx.height = h;
|
||||
ctx.clearRect(0, 0, w, h);
|
||||
|
@ -741,6 +742,7 @@ vAPI.setIcon = (( ) => {
|
|||
return;
|
||||
}
|
||||
iconData[img.i][img.p] = imgData;
|
||||
img.cached = true;
|
||||
}
|
||||
for ( let i = 0; i < iconData.length; i++ ) {
|
||||
if ( iconData[i] ) {
|
||||
|
|
Loading…
Reference in New Issue