Such kind of code is a subject for rising a ticket that will help to simplify this code by calculating requires size from formatting and parameters. I've created issue #685