Skip to content

Commit

Permalink
Do output directly from list
Browse files Browse the repository at this point in the history
Having the prev and next iterators is not much worse than indexing
the vector, and initializing the vector became too verbose.
  • Loading branch information
jkseppan committed Jun 9, 2012
1 parent ae96cad commit 1bade3b
Showing 1 changed file with 14 additions and 19 deletions.
33 changes: 14 additions & 19 deletions ttconv/pprdrv_tt2.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -270,38 +270,33 @@ void GlyphToType3::PSConvert(TTStreamWriter& stream)
points.push_back(points.front());
}

// For output, a vector is more convenient than a list.
std::vector<FlaggedPoint> points_v;
points_v.reserve(points.size());
for (std::list<FlaggedPoint>::iterator it = points.begin();
it != points.end();
it++)
{
points_v.push_back(*it);
}

// The first point
stack(stream, 3);
PSMoveto(stream, points_v.front().x, points_v.front().y);
PSMoveto(stream, points.front().x, points.front().y);

// Step through the remaining points
for (size_t p = 1; p < points_v.size(); )
std::list<FlaggedPoint>::const_iterator it = points.begin();
for (it++; it != points.end(); /* incremented inside */)
{
const FlaggedPoint& point = points_v.at(p);
const FlaggedPoint& point = *it;
if (point.flag == ON_PATH)
{
stack(stream, 3);
PSLineto(stream, point.x, point.y);
p++;
it++;
} else {
assert(points_v.at(p-1).flag == ON_PATH);
assert(points_v.at(p+1).flag == ON_PATH);
std::list<FlaggedPoint>::const_iterator prev = it, next = it;
prev--;
next++;
assert(prev->flag == ON_PATH);
assert(next->flag == ON_PATH);
stack(stream, 7);
PSCurveto(stream,
points_v.at(p-1).x, points_v.at(p-1).y,
prev->x, prev->y,
point.x, point.y,
points_v.at(p+1).x, points_v.at(p+1).y);
p += 2;
next->x, next->y);
it++;
it++;
}
}

Expand Down

0 comments on commit 1bade3b

Please sign in to comment.