[Patch] Fix undeleted "static QFont *_font" in kglobalsettings.cpp
j.sixt at viscovery.net
Fri Dec 5 11:18:22 GMT 2008
Thiago Macieira schrieb:
> On Friday 05 December 2008 08:58:18 Johannes Sixt wrote:
>> Friedrich W. H. Kossebau schrieb:
>>> 1. How to set an array of pointers all to 0 most efficiently (mFonts)?
>> #include <algorithm>
>> std::fill_n(mFonts, FontCount, (QFont*)0);
>> std::fill_n<QFont**,int,QFont*>(mFonts, FontCount, 0);
> Proper C++ way of doing it, but less efficient than a simple memset :-)
Wait a second. Where is it written that the null pointer has the same bit
pattern as sizeof(pointer) consecutive unsigned chars with value '\0'? Hm?
memset is *wrong*.
Moreover, a high-quality implementation of fill_n will expand above
special case into memset anyway.
Add to it that performance is absolutely not an issue in the given
use-case, I'd aim for a correct solution anytime (be it fill_n() or an
More information about the kde-core-devel