background: get rid of nested loop when finishing file loading
At the moment when a file is loaded, we iterate through the list of pending file loads and ignore any unrelated to the file, then iterate all the callers of the related file loads and finish them. In fact, there can only ever be one pending file load related to the file, and we already know it, so we can avoid the ugly nested loops. https://bugzilla.gnome.org/show_bug.cgi?id=722149
This commit is contained in:
parent
e917b7ce0f
commit
fdf264ff64
@ -178,28 +178,22 @@ const BackgroundCache = new Lang.Class({
|
||||
content = null;
|
||||
}
|
||||
|
||||
for (let i = 0; i < this._pendingFileLoads.length; i++) {
|
||||
let pendingLoad = this._pendingFileLoads[i];
|
||||
if (pendingLoad.filename != params.filename ||
|
||||
pendingLoad.style != params.style)
|
||||
continue;
|
||||
|
||||
for (let j = 0; j < pendingLoad.callers.length; j++) {
|
||||
if (pendingLoad.callers[j].onFinished) {
|
||||
for (let i = 0; i < fileLoad.callers.length; i++) {
|
||||
let caller = fileLoad.callers[i];
|
||||
if (caller.onFinished) {
|
||||
let newContent;
|
||||
|
||||
if (content) {
|
||||
newContent = content.copy(pendingLoad.callers[j].monitorIndex,
|
||||
pendingLoad.callers[j].effects);
|
||||
newContent = content.copy(caller.monitorIndex, caller.effects);
|
||||
this._images.push(newContent);
|
||||
}
|
||||
|
||||
pendingLoad.callers[j].onFinished(newContent);
|
||||
caller.onFinished(newContent);
|
||||
}
|
||||
}
|
||||
|
||||
this._pendingFileLoads.splice(i, 1);
|
||||
}
|
||||
let idx = this._pendingFileLoads.indexOf(fileLoad);
|
||||
this._pendingFileLoads.splice(idx, 1);
|
||||
}));
|
||||
},
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user