diff --git a/include/fmt/format.h b/include/fmt/format.h index 54e20de7..aadc9b66 100644 --- a/include/fmt/format.h +++ b/include/fmt/format.h @@ -1844,8 +1844,9 @@ auto write_ptr(OutputIt out, UIntPtr value, const format_specs* specs) FMT_API auto is_printable(uint32_t cp) -> bool; inline auto needs_escape(uint32_t cp) -> bool { - return cp < 0x20 || cp == 0x7f || cp == '"' || cp == '\\' || - !is_printable(cp); + if (cp < 0x20 || cp == 0x7f || cp == '"' || cp == '\\') return true; + if (FMT_OPTIMIZE_SIZE > 1) return false; + return !is_printable(cp); } template struct find_escape_result {