optimized shared_prefix