The rewrite adds a Generator class to replace IndentedString, which handles indentation in a global level. This implementation is cleaner and faster:
Improve dump speed, the original implementation concats string a lot, which will incur massive memory copying. The new implementation uses Array#join when many concats happens so the calls to memcpy() are greatly reduced.
Reduce object allocation since Generator is only allocated once
Simplify base64 data generating and speed it up
And this implementation also fixes compatibility issues with other plist tools:
Fix <key> and <string> bug by incorrect indentation. Now it is safe to use <key> or <string> with new lines inside.
Do not escape quotes because it is not required in XML element content (same behavior as PlistBuddy and libplist)
And this rewrite also adds more options for specifying different xml version and base64 encoded string width (so that I can generate exactly the same plist as generated by Apple's MZXMLMarshalling.framework):
Support base64 data formatting options :base64_width and :base64_indent
Support option :initial_indent when formating a segment of plist
Can specify :xml_version when generating enveloped plist
The rewrite adds a
Generator
class to replaceIndentedString
, which handles indentation in a global level. This implementation is cleaner and faster:Array#join
when many concats happens so the calls tomemcpy()
are greatly reduced.Generator
is only allocated onceAnd this implementation also fixes compatibility issues with other plist tools:
<key>
and<string>
bug by incorrect indentation. Now it is safe to use<key>
or<string>
with new lines inside.And this rewrite also adds more options for specifying different xml version and base64 encoded string width (so that I can generate exactly the same plist as generated by Apple's MZXMLMarshalling.framework):
:base64_width
and:base64_indent
:initial_indent
when formating a segment of plist:xml_version
when generating enveloped plistThe benchmark code:
Benchmark before:
Benchmark after: