patsplat / plist

All-purpose Property List manipulation library
http://www.rubydoc.info/gems/plist
MIT License
306 stars 71 forks source link

Improve plist generator: fix string serialization, speedup, and support more options... #46

Closed luikore closed 7 years ago

luikore commented 7 years ago

The rewrite adds a Generator class to replace IndentedString, which handles indentation in a global level. This implementation is cleaner and faster:

And this implementation also fixes compatibility issues with other plist tools:

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):


The benchmark code:

require 'benchmark'
require 'plist'
require 'stringio'

bin_data = 'f' * 10000
array = 2000.times.map{ StringIO.new bin_data } + 2000.times.map { bin_data }

Benchmark.bm {
  puts Benchmark.measure {
    Plist::Emit.dump array
  }
}

Benchmark before:

       user     system      total        real
  2.010000   0.060000   2.070000 (  2.075573)

Benchmark after:

       user     system      total        real
  0.600000   0.030000   0.630000 (  0.634947)
patsplat commented 7 years ago

@luikore sorry i hadn't gotten back. Why did you close the pull request?