Yes, but the compiler should optimize the obvious cases and there are tricks to use to avoid where the compiler does not optimize.