<feed xmlns='http://www.w3.org/2005/Atom'>
<title>delta/ruby-gems/json.git, branch merge-recent-ruby-changes</title>
<subtitle>github.com: flori/json
</subtitle>
<link rel='alternate' type='text/html' href='http://git.baserock.org/cgit/delta/ruby-gems/json.git/'/>
<entry>
<title>Some more changes from ruby 2.7.0</title>
<updated>2019-12-10T09:43:44+00:00</updated>
<author>
<name>Florian Frank</name>
<email>flori@ping.de</email>
</author>
<published>2019-12-10T09:43:44+00:00</published>
<link rel='alternate' type='text/html' href='http://git.baserock.org/cgit/delta/ruby-gems/json.git/commit/?id=095aeea134ddaa3317137819a84105c02f3043e8'/>
<id>095aeea134ddaa3317137819a84105c02f3043e8</id>
<content type='text'>
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
</pre>
</div>
</content>
</entry>
<entry>
<title>Use newest rubygems</title>
<updated>2019-04-29T14:25:41+00:00</updated>
<author>
<name>Florian Frank</name>
<email>flori@ping.de</email>
</author>
<published>2019-04-29T14:20:57+00:00</published>
<link rel='alternate' type='text/html' href='http://git.baserock.org/cgit/delta/ruby-gems/json.git/commit/?id=55fec9562a2e1117304c3a8e48c0eba879112d55'/>
<id>55fec9562a2e1117304c3a8e48c0eba879112d55</id>
<content type='text'>
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
</pre>
</div>
</content>
</entry>
<entry>
<title>Pass args all #to_json in json/add/*.</title>
<updated>2019-04-29T14:25:33+00:00</updated>
<author>
<name>Sho Hashimoto</name>
<email>sho.hsmt@gmail.com</email>
</author>
<published>2019-01-15T13:16:05+00:00</published>
<link rel='alternate' type='text/html' href='http://git.baserock.org/cgit/delta/ruby-gems/json.git/commit/?id=36a7ef6790881afc813e5d025efddb7ee95d3db4'/>
<id>36a7ef6790881afc813e5d025efddb7ee95d3db4</id>
<content type='text'>
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
</pre>
</div>
</content>
</entry>
<entry>
<title>Add LICENSE file</title>
<updated>2019-04-29T14:18:32+00:00</updated>
<author>
<name>Florian Frank</name>
<email>flori@ping.de</email>
</author>
<published>2019-04-29T14:18:32+00:00</published>
<link rel='alternate' type='text/html' href='http://git.baserock.org/cgit/delta/ruby-gems/json.git/commit/?id=09aa02ede8d7e70a113bfa87be5ed34676d57206'/>
<id>09aa02ede8d7e70a113bfa87be5ed34676d57206</id>
<content type='text'>
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
</pre>
</div>
</content>
</entry>
<entry>
<title>Merge branch 'master' of github.com:flori/json</title>
<updated>2019-04-29T14:02:22+00:00</updated>
<author>
<name>Florian Frank</name>
<email>flori@ping.de</email>
</author>
<published>2019-04-29T14:02:22+00:00</published>
<link rel='alternate' type='text/html' href='http://git.baserock.org/cgit/delta/ruby-gems/json.git/commit/?id=6d12fee7d7c8180da188c02a306f40d96d0edbe2'/>
<id>6d12fee7d7c8180da188c02a306f40d96d0edbe2</id>
<content type='text'>
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
</pre>
</div>
</content>
</entry>
<entry>
<title>Does not check whether illegal utf-8 if string has ascii only.</title>
<updated>2019-04-29T13:58:28+00:00</updated>
<author>
<name>Watson</name>
<email>watson1978@gmail.com</email>
</author>
<published>2018-03-04T14:34:26+00:00</published>
<link rel='alternate' type='text/html' href='http://git.baserock.org/cgit/delta/ruby-gems/json.git/commit/?id=91a24ecac3d722bc3e545fdd0657ed225e91c2df'/>
<id>91a24ecac3d722bc3e545fdd0657ed225e91c2df</id>
<content type='text'>
## Before
```
$ ruby bench_json_generate.rb
Warming up --------------------------------------
                json    25.000  i/100ms
Calculating -------------------------------------
                json    250.478  (± 4.8%) i/s -      1.250k in   5.002238s
```

## After
```
$ ruby bench_json_generate.rb
Warming up --------------------------------------
                json    32.000  i/100ms
Calculating -------------------------------------
                json    360.652  (± 3.6%) i/s -      1.824k in   5.064511s
```

## Test code
```
require 'json'
require 'benchmark/ips'

obj = []

1000.times do |i|
  obj &lt;&lt; {
    :string =&gt; "x" * 100,
    :utf8 =&gt; "あ" * 100
  }
end

Benchmark.ips do |x|
  x.report "json" do |iter|
    count = 0
    while count &lt; iter
      JSON.generate(obj)
      count += 1
    end
  end
end
```
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
## Before
```
$ ruby bench_json_generate.rb
Warming up --------------------------------------
                json    25.000  i/100ms
Calculating -------------------------------------
                json    250.478  (± 4.8%) i/s -      1.250k in   5.002238s
```

## After
```
$ ruby bench_json_generate.rb
Warming up --------------------------------------
                json    32.000  i/100ms
Calculating -------------------------------------
                json    360.652  (± 3.6%) i/s -      1.824k in   5.064511s
```

## Test code
```
require 'json'
require 'benchmark/ips'

obj = []

1000.times do |i|
  obj &lt;&lt; {
    :string =&gt; "x" * 100,
    :utf8 =&gt; "あ" * 100
  }
end

Benchmark.ips do |x|
  x.report "json" do |iter|
    count = 0
    while count &lt; iter
      JSON.generate(obj)
      count += 1
    end
  end
end
```
</pre>
</div>
</content>
</entry>
<entry>
<title>Convert string encoding to UTF-8 only when needed</title>
<updated>2019-04-29T13:58:28+00:00</updated>
<author>
<name>Watson</name>
<email>watson1978@gmail.com</email>
</author>
<published>2018-03-02T16:16:34+00:00</published>
<link rel='alternate' type='text/html' href='http://git.baserock.org/cgit/delta/ruby-gems/json.git/commit/?id=c34d01ff6a18dac04a90b2e0f820cdb1d5c7e1b2'/>
<id>c34d01ff6a18dac04a90b2e0f820cdb1d5c7e1b2</id>
<content type='text'>
## Before
```
$ ruby bench_json_generate.rb
Warming up --------------------------------------
                json   129.000  i/100ms
Calculating -------------------------------------
                json      1.300k (± 2.3%) i/s -      6.579k in   5.064656s
```

## After
```
$ ruby bench_json_generate.rb
Warming up --------------------------------------
                json   189.000  i/100ms
Calculating -------------------------------------
                json      1.964k (± 3.3%) i/s -      9.828k in   5.011237s
```

## Code
```
require 'json'
require 'benchmark/ips'

obj = []

1000.times do |i|
  obj &lt;&lt; {
    "id" =&gt; i,
    :age =&gt; 42,
  }
end

Benchmark.ips do |x|
  x.report "json" do |iter|
    count = 0
    while count &lt; iter
      JSON.generate(obj)
      count += 1
    end
  end
end
```
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
## Before
```
$ ruby bench_json_generate.rb
Warming up --------------------------------------
                json   129.000  i/100ms
Calculating -------------------------------------
                json      1.300k (± 2.3%) i/s -      6.579k in   5.064656s
```

## After
```
$ ruby bench_json_generate.rb
Warming up --------------------------------------
                json   189.000  i/100ms
Calculating -------------------------------------
                json      1.964k (± 3.3%) i/s -      9.828k in   5.011237s
```

## Code
```
require 'json'
require 'benchmark/ips'

obj = []

1000.times do |i|
  obj &lt;&lt; {
    "id" =&gt; i,
    :age =&gt; 42,
  }
end

Benchmark.ips do |x|
  x.report "json" do |iter|
    count = 0
    while count &lt; iter
      JSON.generate(obj)
      count += 1
    end
  end
end
```
</pre>
</div>
</content>
</entry>
<entry>
<title>Convert String encoding using `rb_str_encode()`</title>
<updated>2019-04-29T13:58:28+00:00</updated>
<author>
<name>Watson</name>
<email>watson1978@gmail.com</email>
</author>
<published>2018-03-01T15:51:30+00:00</published>
<link rel='alternate' type='text/html' href='http://git.baserock.org/cgit/delta/ruby-gems/json.git/commit/?id=9ae6d2969cb1e3b927897806e5b632cb2912a0b6'/>
<id>9ae6d2969cb1e3b927897806e5b632cb2912a0b6</id>
<content type='text'>
`rb_funcall` might be slightly heavy to call the Ruby method.
This patch will convert String encoding using `rb_str_encode()` instead of `rb_funcall()`.

## Before
```
$ ruby bench_json_generate.rb
Warming up --------------------------------------
                json    78.000  i/100ms
Calculating -------------------------------------
                json    789.781  (± 2.7%) i/s -      3.978k in   5.041043s
```

## After
```
$ ruby bench_json_generate.rb
Warming up --------------------------------------
                json   129.000  i/100ms
Calculating -------------------------------------
                json      1.300k (± 2.3%) i/s -      6.579k in   5.064656s
```

## Code
```
require 'json'
require 'benchmark/ips'

obj = []

1000.times do |i|
  obj &lt;&lt; {
    "id" =&gt; i,
    :age =&gt; 42,
  }
end

Benchmark.ips do |x|
  x.report "json" do |iter|
    count = 0
    while count &lt; iter
      JSON.generate(obj)
      count += 1
    end
  end
end
```
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
`rb_funcall` might be slightly heavy to call the Ruby method.
This patch will convert String encoding using `rb_str_encode()` instead of `rb_funcall()`.

## Before
```
$ ruby bench_json_generate.rb
Warming up --------------------------------------
                json    78.000  i/100ms
Calculating -------------------------------------
                json    789.781  (± 2.7%) i/s -      3.978k in   5.041043s
```

## After
```
$ ruby bench_json_generate.rb
Warming up --------------------------------------
                json   129.000  i/100ms
Calculating -------------------------------------
                json      1.300k (± 2.3%) i/s -      6.579k in   5.064656s
```

## Code
```
require 'json'
require 'benchmark/ips'

obj = []

1000.times do |i|
  obj &lt;&lt; {
    "id" =&gt; i,
    :age =&gt; 42,
  }
end

Benchmark.ips do |x|
  x.report "json" do |iter|
    count = 0
    while count &lt; iter
      JSON.generate(obj)
      count += 1
    end
  end
end
```
</pre>
</div>
</content>
</entry>
<entry>
<title>Add shortcut converting to String</title>
<updated>2019-04-29T13:58:28+00:00</updated>
<author>
<name>Watson</name>
<email>watson1978@gmail.com</email>
</author>
<published>2018-03-01T15:45:28+00:00</published>
<link rel='alternate' type='text/html' href='http://git.baserock.org/cgit/delta/ruby-gems/json.git/commit/?id=38c0f6dbe4d6709988eecd6b04c59a48066de876'/>
<id>38c0f6dbe4d6709988eecd6b04c59a48066de876</id>
<content type='text'>
In where to convert Hash key to String for json, this patch will add shortcut for String/Symbol in Hash key.

```
$ ruby bench_json_generate.rb
Warming up --------------------------------------
                json    65.000  i/100ms
Calculating -------------------------------------
                json    659.576  (± 1.5%) i/s -      3.315k in   5.027127s
```

```
$ ruby bench_json_generate.rb
Warming up --------------------------------------
                json    78.000  i/100ms
Calculating -------------------------------------
                json    789.781  (± 2.7%) i/s -      3.978k in   5.041043s
```

```
require 'json'
require 'benchmark/ips'

obj = []

1000.times do |i|
  obj &lt;&lt; {
    "id" =&gt; i,
    :age =&gt; 42,
  }
end

Benchmark.ips do |x|
  x.report "json" do |iter|
    count = 0
    while count &lt; iter
      JSON.generate(obj)
      count += 1
    end
  end
end
```
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
In where to convert Hash key to String for json, this patch will add shortcut for String/Symbol in Hash key.

```
$ ruby bench_json_generate.rb
Warming up --------------------------------------
                json    65.000  i/100ms
Calculating -------------------------------------
                json    659.576  (± 1.5%) i/s -      3.315k in   5.027127s
```

```
$ ruby bench_json_generate.rb
Warming up --------------------------------------
                json    78.000  i/100ms
Calculating -------------------------------------
                json    789.781  (± 2.7%) i/s -      3.978k in   5.041043s
```

```
require 'json'
require 'benchmark/ips'

obj = []

1000.times do |i|
  obj &lt;&lt; {
    "id" =&gt; i,
    :age =&gt; 42,
  }
end

Benchmark.ips do |x|
  x.report "json" do |iter|
    count = 0
    while count &lt; iter
      JSON.generate(obj)
      count += 1
    end
  end
end
```
</pre>
</div>
</content>
</entry>
<entry>
<title>Convert Hash object using rb_hash_foreach()</title>
<updated>2019-04-29T13:58:27+00:00</updated>
<author>
<name>Watson</name>
<email>watson1978@gmail.com</email>
</author>
<published>2018-03-01T15:33:18+00:00</published>
<link rel='alternate' type='text/html' href='http://git.baserock.org/cgit/delta/ruby-gems/json.git/commit/?id=a73323dc5e71bf285df3b82e02d3978fb8b2f16f'/>
<id>a73323dc5e71bf285df3b82e02d3978fb8b2f16f</id>
<content type='text'>
To convert Hash convert, this part was using following pseudo code

```
obj.keys.each do |key|
  value = obj[key]
  ...
end
```

and `rb_funcall()` was called for `obj.keys`.
It might be slightly heavy to call the Ruby method.
This patch will iterate to convert Hash object about key/value using `rb_hash_foreach()` Ruby API instead of `rb_funcall()`.

```
$ ruby bench_json_generate.rb
Warming up --------------------------------------
                json    55.000  i/100ms
Calculating -------------------------------------
                json    558.501  (± 1.1%) i/s -      2.805k in   5.022986s
```

```
$ ruby bench_json_generate.rb
Warming up --------------------------------------
                json    65.000  i/100ms
Calculating -------------------------------------
                json    659.576  (± 1.5%) i/s -      3.315k in   5.027127s
```

```
require 'json'
require 'benchmark/ips'

obj = []

1000.times do |i|
  obj &lt;&lt; {
    "id" =&gt; i,
    :age =&gt; 42,
  }
end

Benchmark.ips do |x|
  x.report "json" do |iter|
    count = 0
    while count &lt; iter
      JSON.generate(obj)
      count += 1
    end
  end
end
```
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
To convert Hash convert, this part was using following pseudo code

```
obj.keys.each do |key|
  value = obj[key]
  ...
end
```

and `rb_funcall()` was called for `obj.keys`.
It might be slightly heavy to call the Ruby method.
This patch will iterate to convert Hash object about key/value using `rb_hash_foreach()` Ruby API instead of `rb_funcall()`.

```
$ ruby bench_json_generate.rb
Warming up --------------------------------------
                json    55.000  i/100ms
Calculating -------------------------------------
                json    558.501  (± 1.1%) i/s -      2.805k in   5.022986s
```

```
$ ruby bench_json_generate.rb
Warming up --------------------------------------
                json    65.000  i/100ms
Calculating -------------------------------------
                json    659.576  (± 1.5%) i/s -      3.315k in   5.027127s
```

```
require 'json'
require 'benchmark/ips'

obj = []

1000.times do |i|
  obj &lt;&lt; {
    "id" =&gt; i,
    :age =&gt; 42,
  }
end

Benchmark.ips do |x|
  x.report "json" do |iter|
    count = 0
    while count &lt; iter
      JSON.generate(obj)
      count += 1
    end
  end
end
```
</pre>
</div>
</content>
</entry>
</feed>
