ccNcompt currently uses a 2-pass algorithm, but there is a more efficient single pass algorithm described in "A linear-time component-labeling algorithm using contour tracing technique" (2004):
http://citeseerx.ist.psu.edu/viewdoc/summary?doi=10.1.1.95.6330
And here is an implementation in C: http://www.codeproject.com/Tips/407172/Connected-Component-Labeling-and-Vectorization
There's also pseudocode in the wikipedia article: https://en.wikipedia.org/wiki/Connected-component_labeling#One-pass_version
That's fine to add a new one pass algorithm but please give it a new function name! (The old one has stood the test of time.)
Ticket moved from /p/pdl/bugs/333/
Lowering the priority but performance improvement contributions are always welcome. Leaving the request ticket open in case someone wishes to follow up further.
Tracked at https://github.com/PDLPorters/pdl/issues/326