New wbxml encoder
The old encoder had very bad performance on larger email attachments (or any
xml that is more than a couple of kbytes).
The way the encoder worked is:
- We get a DOMDocument in memory representation of the xml
- The document is serialized to a string
- The serialized xml is parsed using the xml_parser
- The generated callbacks are used to emit wbxml again
This was primarily very slow because the data handler set by xml_set_character_data_handler
is called a ton (at least twice for every line of the attachment), so we
spend all our time concatenating strings instead of doing something
useful.
The new encoder simply iterates over the already available in-memory
structure and emits wbxml directly, which makes the process a lot
faster, especially if we deal with very large values such as
attachments.
The test was created by running the old codepath (which I'm going to
remove in the next commit), and storing the wbxml result base64_encoded
(because binary). We then simply ensure that we continue to produce the
same wbxml as before.