Skip to content

Simplify ttconv loop #938

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Jun 9, 2012
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Simplify a loop in ttconv
Replace a while loop with complicated break and continue cases by
a for loop that has the iteration and end-condition testing in one
place only.
  • Loading branch information
jkseppan committed Jun 9, 2012
commit 067bf0c7c8bcdfb1f83875b5dd916ededcbcc0fa
34 changes: 6 additions & 28 deletions ttconv/pprdrv_tt2.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -203,8 +203,9 @@ void GlyphToType3::PSConvert(TTStreamWriter& stream)
/* Step thru the coutours. */
/* I believe that a contour is a detatched */
/* set of curves and lines. */
i=j=k=0;
while ( i < num_ctr )
for(i = j = k = 0;
i != NOMOREOUTCTR && i < num_ctr;
k = nextinctr(i, k), (k == NOMOREINCTR && (i = k = nextoutctr(i))))
{
// A TrueType contour consists of on-path and off-path points.
// Two consecutive on-path points are to be joined with a
Expand All @@ -224,24 +225,13 @@ void GlyphToType3::PSConvert(TTStreamWriter& stream)
}
}

// For any two consecutive off-path points, insert the implied
// on-path point.

if (points.size() == 0) {
k=nextinctr(i,k);

if (k==NOMOREINCTR)
{
i=k=nextoutctr(i);
}

if (i==NOMOREOUTCTR)
{
break;
}
// Don't try to access the last element of an empty list
continue;
}

// For any two consecutive off-path points, insert the implied
// on-path point.
FlaggedPoint prev = points.back();
for (std::list<FlaggedPoint>::iterator it = points.begin();
it != points.end();
Expand Down Expand Up @@ -296,18 +286,6 @@ void GlyphToType3::PSConvert(TTStreamWriter& stream)
p += 2;
}
}

k=nextinctr(i,k);

if (k==NOMOREINCTR)
{
i=k=nextoutctr(i);
}

if (i==NOMOREOUTCTR)
{
break;
}
}

/* Now, we can fill the whole thing. */
Expand Down