|Zest's GraphNode#initFigure() and Graph#registerItem() called twice unnecessarily? [message #243395]
||Wed, 04 June 2008 18:43
| Stefan Tucker
Registered: July 2009
It looks to me as if GraphNode's constructor calls |
GraphNode#initFigure() twice, which allocates the node's GraphLabel twice.
1. Instantiate GraphNode(g, 0, "z")
2. GraphNode's ctor calls initModel()
3. That calls graph.registerItem(this)
4. That calls item.getFigure()
5. this.nodeFigure is null, so it calls initFigure() which calls
createFigureForModel() and sets this.nodeFigure
6. It returns back up to the ctor, which promptly calls initFigure()
(again), even though this.nodeFigure is already not null.
7. Finally, GraphNode's ctor calls registerItem(this) again.
(initModel() called it already.)
These unnecessary allocations and calls probably affect performance and
make Zest less efficient than it could be.
I suspect either the ctor shouldn't call initFigure() itself or
initFigure() should only call createFigureForModel() if this.nodeFigure
P.S. Why does initFigure() set this.nodeFigure as well as return it so
that the caller can set this.nodeFigure (again)?
Powered by FUDForum
. Page generated in 0.01388 seconds