Mineserver Community
Mineserver => Discussion => Topic started by: Josko88 on November 27, 2010, 09:13:27 pm
-
Hello,
can I suggest using (const) references passing where available (ie. std::strings) and using prefix instead of postfix operators (seems like you're using both so at least decide which one ;)). Not the biggest jumps in performance but they won't slow things down for sure.
-
Should ALWAYS use prefix over postfix unless you would be copying the object anyway.
Always avoid using the copy constructor for less overhead!
-
Yes, these are both good programming, even though they are the first things to be optimized with most compilers, the const reference is more important then incrementing being post or pre, unless its an object which is being copied because its had the increment operators overloaded..
-
Ya, good compilers won't return a temporary value with post-increment if no operation is being performed on it. And if an operation is done on it, it was most likely intended to be performed on a post-increment.
So ya, the only time you may gain a performance gain on post vs pre increment is on an object where the operator is overloaded - good call.