avoid potentially quadratic loop (Hossein).


git-svn-id: svn://svn.code.sf.net/p/cp2k/code/trunk@12966 bac0169d-1eea-4375-b5f6-f89d2ced9994