mikejd42 wrote: > --- In [email protected], Paul Herring <pauljherr...@...> wrote: >> On Thu, May 14, 2009 at 12:56 PM, mikejd42 <mikej...@...> wrote: >> >>> Logically you want to shift right one. [...] >>> Far too many programmers are not trained to optimize and scrutinize their >>> code. >> You don't appear to be one of them however. The correct way to >> optimise is to use a profiler first, second and third, and only then >> when you think there is a problem with speed/memory. > > Where is this hostility coming from? I suggest a perfectly valid bit of code > and you take it upon yourself to slam me! > > I am sorry that my doing a shift function upsets you so but it is valid code > and 30 years of experience has provided me with the knowledge that it is > efficient and optimum. It is not guessing.
I try to not pull the "'x' years of experience" card out too often. Yes, it trumps everything (assuming the person actually has more years of experience) but should only be pulled out as the last resort. I get to win the argument...but was it worth winning? This thread has turned into nitpicking. Compilers are smart enough to convert /2 into >>1 operations if it sees the opportunity to optimize. That said, I use >> 1 - but only if it makes sense in the context and how lazy I'm feeling that day. Graphics operations have historically utilized shifting, so it makes sense there. Dropping a shift somewhere else - say doing lightweight math where coming back to it later will make me say, "Why did I do that?" and waste time trying to figure it out is obviously not an optimization - of my time anyway. -- Thomas Hruska CubicleSoft President Ph: 517-803-4197 *NEW* MyTaskFocus 1.1 Get on task. Stay on task. http://www.CubicleSoft.com/MyTaskFocus/
