This one doesn't do a redundant final incrementation.
Says who? One of the mashines I had do use such loop it had an extra
cost of dest--, source--; at the end of the loop. The cause: the
mashine had an mashine code like
*dest++ = *source++;
as single memory to memory instruction, but not equivalent without the
increments.
So to get the final pointers right both hand needed an separate
decrement to fit the "as if" clause.
Says who? See above.
Best optimum because 'as if' qualifies as 'really done'. Except: don't
save spaces!
while (*dest++ = *source++) ;
= that little space helps to see that
the body is empty. More readable would be: bring the semicolon on the
next line on one more indention.
Yep.
As I found out since about 1990: save typing but don't save on
meaningfull comments so good as possible and let the copiler do the
optimising on mashine code level. It will do better as you ever will
get it in acceptable time.
Meaningfull comments needed for maintenance after haing the code
untouched for 12 month or longer. Save typing means: write compact
code without consideration of beginners in programming but don't
require with real experts with more than 5 years extensive experience.
Don't mircro optimazion by hand because the next compiler version may
turn back that in its absolute contrary. Rethink the algorithm you use
will give a better optimazion anyway.
Use the highest possible warning level even on the final compile with
highest optimazion, remove any diagnostic the compiler may give by
resolving the cause - but use casts only when you have rethinking the
logic and you knows exactly that you knows absolutely that you knows
exactly why you have to cast and there is nothing else that can be
done, but never cast when it is only to get the compiler quiet.
--
Tschau/Bye
Herbert
Visit
http://www.ecomstation.de the home of german eComStation
eComStation 1.2 Deutsch ist da!