Hello,
The last few days I've spent on improving the performance of the object snapper. It used to take ages (e.g about 6 seconds on my machine) to move a simple rectangle over a large text box, but I've managed to reduce this significantly (i.e. < 1 sec.!). This was with both snapping to paths and snapping to nodes turned on. For this I had to refactor the object snapper code significantly, so I might have introduced new bugs or regressions. Please be aware of this and report any suspicious behavior, so we can have both fast and robust snapping in v0.46!
Please note that the performance has only increased when using the selector tool for transforming a number of points, e.g. when dragging a selection. Using the node tool to drag a single node will not benefit from this.
Now for those of you interested in some technical details:
Before, for _every_ point in the selection being transformed (using the selector tool), Inkscape would search for snapping candidates, build a list of nodes and paths, and finally call convertWithBackData(). Only then would it snap this single point and start all over again for the next point in the selection. Now we only do this collecting and converting stuff once, store the results, and then snap all points in the selection (using the stored data). Not having to call convertWithBackData really helps a lot! I think that in many common cases this improves the performance dramatically. However, there might also be some (rare?) cases showing a performance decrease, because the number of candidates might be higher. Before we would search for candidates within range of a single point. Now we search for candidates within range of any of the snappoints in the selection, so our list of candidates is longer which gives us more combinations to check. I do think that this will not really be an issue, as this use case is less common and there's still a performance gain at the same time.
Any feedback is appreciated!
Regards,
Diederik