Unnecessary iterations in trimDot

Due to the array being changed during the loop, storing the length at the beginning is leading to unnecessary iteration if a ".." or a "." is found in the name. This may also be harmful in the future as this is probably not wanted.