Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This PR introduces a HalfedgeList object (a doubly-linked list) to replace arrays in Voronoi cells. It seems a lot of time is spent on garbage collection when the createEdge method is called, since it needs to push new objects to the halfedges array of the corresponding cells.
At least in Chrome and Safari, this change gives a significant speed up when running the benchmark and Lloyd's relaxation demos with 10000 vertices.
Please note that this change would break code that needs to iterate through the existing halfedges array of the cell object though.
Iterating through halfedges would need to be done in this manner:
Also, the HalfedgeList object is declared within the prototype of the Cell object. I'm not sure whether this is the right way to go or not. I tried declaring this within the prototype of the Voronoi object, like the Cell and Halfedge objects, but couldn't find a way to call the HalfedgeList constructor from within the Cell object's methods.