[ ] Use a C array for HGEdge::intermediate_points instead of a list or vector.
[ ] Include a separate intermediate_count in unused space before format. I'm thinking uint16_t, though could use uint32_t if necessary.
[ ] What's the largest intermediate_points.size() of any existing edge?
[ ] Any significant speedup from using raw coords (2 doubles) instead of HGVertex*?
Proposed here; referenced here. Carving out a new issue mostly for a good place to leave this code:
HGEdge collapse ctor
// find which endpoints aren't the vertex we're collapsing and set them as our new
// endpoints, and at the same time, build up our list of intermediate vertices
auto e1_count = edge1->intermediate_count,
e2_count = edge2->intermediate_count;
auto new_p = intermediate_points = new HGVertex*[intermediate_count = e1_count+1+e2_count];
if (edge1->vertex1 == vertex)
{ vertex1 = edge1->vertex2;
auto old_p = edge1->intermediate_points + e1_count;
while (old_p > edge1->intermediate_points) *new_p++ = *--old_p;
}
else { vertex1 = edge1->vertex1;
memcpy(new_p , edge1->intermediate_points , e1_count*sizeof(HGVertex*));
new_p += e1_count;
}
*new_p++ = vertex;
if (edge2->vertex1 == vertex)
{ vertex2 = edge2->vertex2;
memcpy(new_p , edge2->intermediate_points , e2_count*sizeof(HGVertex*));
}
else { vertex2 = edge2->vertex1;
auto old_p = edge2->intermediate_points + e2_count;
while (old_p > edge2->intermediate_points) *new_p++ = *--old_p;
}
[ ] We're down 1 line due to deleting 5 lines of debug text.
Restoring them would make a cleaner commit diff. Do I prefer a clean diff or clean code?
FWIW, I just now uncommented 4 of them to grep -c them.
[ ] Consider swapping the 1st if & else for a sense of visual continuity, pattern-spotting, yadda yadda.
HGEdge::intermediate_points
instead of a list or vector.intermediate_count
in unused space beforeformat
. I'm thinkinguint16_t
, though could useuint32_t
if necessary.intermediate_points.size()
of any existing edge?HGVertex*
?Proposed here; referenced here. Carving out a new issue mostly for a good place to leave this code:
HGEdge
collapse ctorgrep -c
them.std::string HGEdge::intermediate_point_string()
HGEdge::str()