cnc-club / gcodetools

CAM extension for Inkscape to export paths to Gcode
257 stars 99 forks source link

1000x faster duplicate points removal #19

Open shimpe opened 5 years ago

shimpe commented 5 years ago

the current implementation uses an algorithm with O(n^2) time complexity which is very expensive in case of many points; the proposed implementation is O(n).

To give an idea: the current algorithm on a list of 10000 integers between 0 and 5000 takes around 8.7 seconds on my pc, whereas the new routine takes around 0.002 seconds (the new routine doesn't keep the original ordering of points but as far as I can tell it's not needed)