Optimized compact method by using a counter in place of Array.prototype.push()
Merge pull request #421 from robertmesserle/master

Optimized compact method. [ci skip]