optimized fmt_pack to avoid pointless memory [re]allocations