<feed xmlns='http://www.w3.org/2005/Atom'>
<title>ruby.git/ext/json/generator/generator.c, branch v3_0_4</title>
<subtitle>The Ruby Programming Language</subtitle>
<link rel='alternate' type='text/html' href='https://git.ruby-lang.org/ruby.git/'/>
<entry>
<title>[json] Make json Ractor safe</title>
<updated>2020-12-21T13:10:43+00:00</updated>
<author>
<name>Kenta Murata</name>
<email>mrkn@mrkn.jp</email>
</author>
<published>2020-12-21T06:57:42+00:00</published>
<link rel='alternate' type='text/html' href='https://git.ruby-lang.org/ruby.git/commit/?id=14d7d1df25bbefadfc385042d541b4afc31e4c1b'/>
<id>14d7d1df25bbefadfc385042d541b4afc31e4c1b</id>
<content type='text'>
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
</pre>
</div>
</content>
</entry>
<entry>
<title>[json] Stop using prototype objects</title>
<updated>2020-12-21T13:10:33+00:00</updated>
<author>
<name>Kenta Murata</name>
<email>mrkn@mrkn.jp</email>
</author>
<published>2020-12-20T03:17:32+00:00</published>
<link rel='alternate' type='text/html' href='https://git.ruby-lang.org/ruby.git/commit/?id=98cc15ed1e9193e17fad6b87cccf8f8b5ade7801'/>
<id>98cc15ed1e9193e17fad6b87cccf8f8b5ade7801</id>
<content type='text'>
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
</pre>
</div>
</content>
</entry>
<entry>
<title>Add an option to escape forward slash character</title>
<updated>2020-09-25T08:28:42+00:00</updated>
<author>
<name>Jean Boussier</name>
<email>jean.boussier@gmail.com</email>
</author>
<published>2020-01-30T11:48:05+00:00</published>
<link rel='alternate' type='text/html' href='https://git.ruby-lang.org/ruby.git/commit/?id=e1659af3724e2320e9f2f2bd7cf602686e8aa523'/>
<id>e1659af3724e2320e9f2f2bd7cf602686e8aa523</id>
<content type='text'>
Squashed commit of the following:

commit 26d181059989279a79c433cedcd893b4f52e42ee
Author: Francois Chagnon &lt;francois.chagnon@jadedpixel.com&gt;
Date:   Tue Sep 15 21:17:34 2015 +0000

    add config options for escape_slash

commit fa282334051b16df91ca097dd7304b46f3bc7719
Author: Francois Chagnon &lt;francois.chagnon@jadedpixel.com&gt;
Date:   Mon Feb 9 21:09:33 2015 +0000

    add forward slash to escape character
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
Squashed commit of the following:

commit 26d181059989279a79c433cedcd893b4f52e42ee
Author: Francois Chagnon &lt;francois.chagnon@jadedpixel.com&gt;
Date:   Tue Sep 15 21:17:34 2015 +0000

    add config options for escape_slash

commit fa282334051b16df91ca097dd7304b46f3bc7719
Author: Francois Chagnon &lt;francois.chagnon@jadedpixel.com&gt;
Date:   Mon Feb 9 21:09:33 2015 +0000

    add forward slash to escape character
</pre>
</div>
</content>
</entry>
<entry>
<title>[flori/json] Typo fix</title>
<updated>2020-07-01T09:47:51+00:00</updated>
<author>
<name>Marc-Andre Lafortune</name>
<email>github@marc-andre.ca</email>
</author>
<published>2020-06-30T04:28:23+00:00</published>
<link rel='alternate' type='text/html' href='https://git.ruby-lang.org/ruby.git/commit/?id=26041da2fbca4cfeffaee13b66f90310d5d72e18'/>
<id>26041da2fbca4cfeffaee13b66f90310d5d72e18</id>
<content type='text'>
https://github.com/flori/json/commit/26c1769969
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
https://github.com/flori/json/commit/26c1769969
</pre>
</div>
</content>
</entry>
<entry>
<title>[flori/json] Add :nodoc: for GeneratorMethods</title>
<updated>2020-01-06T06:13:50+00:00</updated>
<author>
<name>zverok</name>
<email>zverok.offline@gmail.com</email>
</author>
<published>2018-03-08T18:32:00+00:00</published>
<link rel='alternate' type='text/html' href='https://git.ruby-lang.org/ruby.git/commit/?id=7f1e3a7b7ceb6e5bdfee13da50588d855156b7e0'/>
<id>7f1e3a7b7ceb6e5bdfee13da50588d855156b7e0</id>
<content type='text'>
https://github.com/flori/json/commit/2f3f44c180
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
https://github.com/flori/json/commit/2f3f44c180
</pre>
</div>
</content>
</entry>
<entry>
<title>Remove unused constant.</title>
<updated>2019-10-17T20:35:26+00:00</updated>
<author>
<name>Aaron Patterson</name>
<email>tenderlove@ruby-lang.org</email>
</author>
<published>2019-10-17T20:35:26+00:00</published>
<link rel='alternate' type='text/html' href='https://git.ruby-lang.org/ruby.git/commit/?id=1d564acedc820e91c585cb4850844a09f9a6af96'/>
<id>1d564acedc820e91c585cb4850844a09f9a6af96</id>
<content type='text'>
This constant isn't used, so lets remove it.
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
This constant isn't used, so lets remove it.
</pre>
</div>
</content>
</entry>
<entry>
<title>Look up constant instead of caching in a global</title>
<updated>2019-10-17T20:30:09+00:00</updated>
<author>
<name>Aaron Patterson</name>
<email>tenderlove@ruby-lang.org</email>
</author>
<published>2019-10-17T20:30:09+00:00</published>
<link rel='alternate' type='text/html' href='https://git.ruby-lang.org/ruby.git/commit/?id=9026e12f93bb0f3f63d7449cdb5eabb2e660088f'/>
<id>9026e12f93bb0f3f63d7449cdb5eabb2e660088f</id>
<content type='text'>
The global can go bad if the compactor runs, so we need to look up the
constant instead of caching it in a global.
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
The global can go bad if the compactor runs, so we need to look up the
constant instead of caching it in a global.
</pre>
</div>
</content>
</entry>
<entry>
<title>[flori/json] Add ascii_only option to JSON::Ext::Generator::State.new.</title>
<updated>2019-10-14T10:54:49+00:00</updated>
<author>
<name>Sho Hashimoto</name>
<email>sho.hsmt@gmail.com</email>
</author>
<published>2019-01-08T00:12:05+00:00</published>
<link rel='alternate' type='text/html' href='https://git.ruby-lang.org/ruby.git/commit/?id=308bbb4e10d247063889ebd9ba957e62f17978a5'/>
<id>308bbb4e10d247063889ebd9ba957e62f17978a5</id>
<content type='text'>
https://github.com/flori/json/commit/0e99a9aac5
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
https://github.com/flori/json/commit/0e99a9aac5
</pre>
</div>
</content>
</entry>
<entry>
<title>[flori/json] Add shortcut converting to String</title>
<updated>2019-10-14T10:54:49+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='https://git.ruby-lang.org/ruby.git/commit/?id=98a9445db943c747e8d98cf7236e891eb48b5be0'/>
<id>98a9445db943c747e8d98cf7236e891eb48b5be0</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
```

https://github.com/flori/json/commit/38c0f6dbe4
</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
```

https://github.com/flori/json/commit/38c0f6dbe4
</pre>
</div>
</content>
</entry>
<entry>
<title>[flori/json] Convert Hash object using rb_hash_foreach()</title>
<updated>2019-10-14T10:54:49+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='https://git.ruby-lang.org/ruby.git/commit/?id=a2f9c38a718eecef6795b4a8667589c0ef68b737'/>
<id>a2f9c38a718eecef6795b4a8667589c0ef68b737</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
```

https://github.com/flori/json/commit/a73323dc5e
</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
```

https://github.com/flori/json/commit/a73323dc5e
</pre>
</div>
</content>
</entry>
</feed>
