wvanbergen/chunky_png — pull request #73 by luikore (2014-10-23 15:45:49+00:00)
Title: Make crop much faster and take much less memory

The `+=` operation on array allocates a new array and copies everything on every pixel, which makes `crop` very very slow. This little change of `concat` can speed up cropping a lot.

Here's the benchmark on a 1200x1200 image:

```ruby
# bm.rb
require "chunky_png"
require "oily_png" # just make `.from_file` faster, no effect on `.crop`
png = ChunkyPNG::Image.from_file '1.png'
10.times {
png.crop 0, 0, 600, 600
}
```

Before

```sh
$ gtime -f "%e seconds, %M bytes" ruby bm.rb
0.34 seconds, 286752768 bytes
```

After

```sh
$ gtime -f "%e seconds, %M bytes" ruby bm.rb
8.65 seconds, 411205632 bytes
```