Right-size |chars.length| and |type.length| in bidi().

This lets the JS engine resize the array elements buffer immediately,
thus avoiding some intermediate resizings. This can save multiple MiBs
of reallocation in text-heavy files.
Merge pull request #5096 from nnethercote/bidi-length

Right-size |chars.length| and |type.length| in bidi().