-
Notifications
You must be signed in to change notification settings - Fork 75
executable size is too large 8000 #9
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
I think header-only can be an advantage if you value convenience over code size. If there's a way to get both then I'd certainly like to hear about it. I'm not sure I quite understand what you mean by an external_linkage_safe_printf. One possibility that I've considered in the past is to compute an array of Formatter objects (one for each argument). Each formatter in the array would simply wrap a reference to an argument and know how to format it onto a std::ostream, thus capturing the required type information. There's multiple advantages to this:
Is this the kind of thing you had in mind? Of course, there's also some downsides:
|
BTW, this is related to issue #7. tinyformat code size used to be a lot smaller (at least with g++), but it's gotten worse with recent versions. |
I've pushed some experimental changes to help address this in the formatter_list branch (C++11 support only for now). The version in git still has everything in the header, but breaking out the formatImpl() function and other functions used by it into a tinyformat.cpp leads to a really nice code footprint: ./bloat_test.sh -DUSE_TINYFORMAT -std=c++0x -O3 -DNDEBUG real 0m18.861s That's getting quite respectably small - a factor of about 10x improvement over the current master in fact :-) |
I'd say this is well and truly fixed as of 38173bb. With gcc-4.8.2, I now get:
Notably, this is with the header-only version so there's need to compromise on convenience, at least with gcc 4.8. Note also that the same version weighs in at 80K stripped for an iostreams implementation of the same formatting, so there's very little overhead here. |
header only is not an advantage for safe printf, A more efficient implementation should just use variadic template to compute a type-signature-array, and pass to an external_linkage_safe_printf function along with other parameters
The text was updated successfully, but these errors were encountered: