It seems to me that calling string.length() each time takes significantly longer than just accessing a variable.