https://gcc.gnu.org/bugzilla/show_bug.cgi?id=81772

            Bug ID: 81772
           Summary: Compile-time snprintf optimization
           Product: gcc
           Version: 5.4.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c
          Assignee: unassigned at gcc dot gnu.org
          Reporter: bugzi...@poradnik-webmastera.com
  Target Milestone: ---

snprintf is slow. This is caused not only by format string handling, but there
is also some internal fault with string handling - see
https://sourceware.org/bugzilla/show_bug.cgi?id=21905 . Because of this it
would be nice if gcc could perform some compile-time optimization. The best
would be to parse format string at compile time and generate appropriate code
for it, so there would be no format parsing at runtime at all. However any
partial optimization here would be helpful. I found that sprintf with %s format
is replaced with strcpy. snprintf with %s format could be replaced with strlcpy
- unfortunately is is not supported yet by gcc/glibc, so other approach is
needed (or implement strlcpy/strlcat and use them :))

Reply via email to