Fix some performance problems reported by cppcheck.