The duplicated edges were caused by 'oversubdivided' edges, i.e. edges
where some of the vertices on them are only connected to two polygons.
For most 'normal' meshes this shouldn't occurr, or only very little, so
the performance impact of this change should be neglegible. In practice
this is also avoidable by triangulating the mesh first.
The fix finds these vertices and 'dissolves' them so that only one edge
is created.
Blend file with bad mesh (tested with BKE_mesh_is_valid):
