rewrite ComparisonCompactor, making it thread-safe and eliminating duplicate prefix/suffix computing