Optimize HandMorph::morphAtPointer a lot

On large morph hierarchies this goes from ~85% CPU usage when moving the mouse around to ~5%.
pull/3/merge
Nathan Dinsmore 2015-06-17 18:24:54 -04:00
rodzic 013e2740d8
commit c8cbbeb2ad
1 zmienionych plików z 20 dodań i 21 usunięć

Wyświetl plik

@ -9392,28 +9392,27 @@ HandMorph.prototype.changed = function () {
// HandMorph navigation:
HandMorph.prototype.morphAtPointer = function () {
var morphs = this.world.allChildren().slice(0).reverse(),
myself = this,
result = null;
morphs.forEach(function (m) {
if (m.visibleBounds().containsPoint(myself.bounds.origin) &&
result === null &&
m.isVisible &&
(m.noticesTransparentClick ||
(!m.isTransparentAt(myself.bounds.origin))) &&
(!(m instanceof ShadowMorph)) &&
m.allParents().every(function (each) {
return each.isVisible;
})) {
result = m;
}
});
if (result !== null) {
return result;
Morph.prototype.topMorphAt = function (p) {
if (!this.isVisible) return null;
for (var c = this.children, i = c.length; i--;) {
var result = c[i].topMorphAt(p);
if (result) return result;
}
return this.world;
return this.bounds.containsPoint(p) ? this : null;
};
FrameMorph.prototype.topMorphAt = function (p) {
if (!(this.isVisible && this.bounds.containsPoint(p))) return null;
for (var c = this.children, i = c.length; i--;) {
var result = c[i].topMorphAt(p);
if (result) return result;
}
return this;
};
ShadowMorph.prototype.topMorphAt = function () {
return null;
};
HandMorph.prototype.morphAtPointer = function () {
return this.world.topMorphAt(this.bounds.origin);
};
/*