Double spaces optimization

Moved the sequential space check into the whitespaceHtmlChars and htmlChars loop

Change-Id: I835cccf868fed851f25f5ccbba1386697b0ea66b