Dawit Alemayehu wrote: > ----------------------------------------------------------- > This is an automatically generated e-mail. To reply, visit: > http://svn.reviewboard.kde.org/r/5775/#review8543 > ----------------------------------------------------------- > > > I am personally not conveinced the need for changing from usleep to > nanosleep in this particular instance. IOW, usleep is sufficient in this > case to warrant a change regardless of when that system call was made > available... > > > /trunk/KDE/kdelibs/kdecore/util/kshareddatacache.cpp > <http://svn.reviewboard.kde.org/r/5775/#comment8911> > > Hmm... why do unnecessary calculations in fast loops ? Surely > "1<<21*10" can be hard coded with a #define. > > > > /trunk/KDE/kdelibs/kdecore/util/kshareddatacache.cpp > <http://svn.reviewboard.kde.org/r/5775/#comment8912> > > And of course if speed is an issue, which seemed to be the case since a > left shift arithmetic was done above, this can be changed to a equivalent > left shift operation: > > usecSleepTime.tv_nsec = usecSleepTime.tv_nsec << 1;
No, please don't do that. That advise is outdated some years. This doesn't get any benefit at all since every compiler not completely outdated will generate the same code from "a * 2" and "a << 1". They will also do precalculations of constants. So this would also make the code unreadable. See e.g. http://dl.fefe.de/optimizer-isec.pdf for more information on compiler optimizations. Eike
signature.asc
Description: This is a digitally signed message part.