Reuse string length instead of recomputing it

The IMAP scanner uses the length of the underlying string in several
places. It is not necessary to recompute it every time it is needed, but
this is what it does. It should only be computed once, or at least when
the underlying string is set.

Store the length of the string in a private instance variable, and
compute it only when the string is set.

Signed-off-by: Marcus Karlsson <mk@acc.umu.se>