perhaps store str.len before this? Or maybe it's optimized away