Optimize currency-related format() code