Minor performance improvement...

This commit is contained in:
Paulo Gustavo Veiga 2012-07-07 13:18:27 -03:00
parent f3da916965
commit 80940b8529
7 changed files with 83 additions and 81 deletions

View File

@ -139,9 +139,7 @@ mindplot.ConnectionLine = new Class({
else {
x = -mindplot.Topic.CONNECTOR_WIDTH;
}
console.log("conector:" + x + ", " + y);
connector.setPosition(x, y);
}
},

View File

@ -682,7 +682,7 @@ mindplot.Designer = new Class({
});
var relIds = topics.map(function (rel) {
var relIds = relation.map(function (rel) {
return rel.getId();
});

View File

@ -138,7 +138,10 @@ mindplot.layout.Node = new Class({
$assert($defined(position.x), "x can not be null");
$assert($defined(position.y), "y can not be null");
this._setProperty('position', Object.clone(position));
// This is a performance improvement to avoid movements that really could be avoided.
var currentPos = this.getPosition();
if (currentPos == null || Math.abs(currentPos.x - position.x) > 2 || Math.abs(currentPos.y - position.y) > 2)
this._setProperty('position', position);
},
_setProperty:function (key, value) {

View File

@ -111,14 +111,15 @@ mindplot.model.Mindmap = new Class({
},
findNodeById:function (id) {
var result;
for (var i = 0; i < this._branches; i++) {
var result = null;
for (var i = 0; i < this._branches.length; i++) {
var branch = this._branches[i];
result = branch.findNodeById(id)
result = branch.findNodeById(id);
if (result) {
break;
}
}
return result;
}
}
);

View File

@ -189,7 +189,7 @@ mindplot.model.NodeModel = new Class({
findNodeById : function(id) {
var result = null;
if (this.getId() == id) {
return this;
result = this;
} else {
var children = this.getChildren();
for (var i = 0; i < children.length; i++) {

View File

@ -411,7 +411,7 @@ mindplot.persistence.XMLSerializer_Pela = new Class({
return null;
}
// Is the connections points valid ?. If it's not, do not load the relationship ...
if (mindmap.findNodeById(srcId) == null || mindmap.findNodeById(destId)) {
if (mindmap.findNodeById(srcId) == null || mindmap.findNodeById(destId)==null) {
return null;
}