On Sun, 6 Feb 2022, Pali Rohár wrote:

Mark _vscprintf() and _scprintf() functions with attribute pure as their
return value depends only on passed arguments.

In function __ms_vsnprintf() check only for n==0 and move _vscprintf() call
at the end of function. This allows LTO to optimize out _vscprintf() call
from __ms_vsnprintf() function if caller of snprintf() or vsnprintf() does
not use return value.

It works because _vscprintf() is direct return value of __ms_vsnprintf()
and function marked as pure is automatically optimized out if its return
value is not used.
---
mingw-w64-crt/stdio/vsnprintf.c | 10 +++++-----
mingw-w64-headers/crt/stdio.h   |  3 +++
2 files changed, 8 insertions(+), 5 deletions(-)

This looks ok to me, so I pushed it.

// Martin

_______________________________________________
Mingw-w64-public mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/mingw-w64-public

Reply via email to