flori/json — pull request #203 by vipulnsward (2014-04-09 06:10:10+00:00)
Title: Perf. improvements to Hash#to_json in pure implementation generator.

Perf. improvements to Hash#to_json in pure implementation generator:
- Use `.each` instead of `for` for iterating over elements.
- Initialize `delim`, `result` vars with initial states instead of appending `state.object_nl` later.
- Use faster string interpolation where possible on `Hash#json_transform` instead of appending strings repeatedly.

Benchmark:

```ruby
hash ={:a => {:a => {:a => {:a => {:a => 1}}}}}
require 'benchmark/ips'
Benchmark.ips do |x|
x.report("to_json ") { hash.to_json}
end
```

```yaml
Before:
Calculating -------------------------------------
to_json 4990 i/100ms
-------------------------------------------------
to_json 52970.8 (±5.9%) i/s - 264470 in 5.010558s

After:
Calculating -------------------------------------
to_json 5253 i/100ms
-------------------------------------------------
to_json 55998.6 (±5.9%) i/s - 283662 in 5.083350s
```