<feed xmlns='http://www.w3.org/2005/Atom'>
<title>delta/ruby.git/ext/json, branch ruby_2_7</title>
<subtitle>github.com: ruby/ruby.git
</subtitle>
<link rel='alternate' type='text/html' href='http://trove.baserock.org/cgit/delta/ruby.git/'/>
<entry>
<title>Import json-2.3.0 from flori/json</title>
<updated>2019-12-12T00:14:09+00:00</updated>
<author>
<name>Hiroshi SHIBATA</name>
<email>hsbt@ruby-lang.org</email>
</author>
<published>2019-12-12T00:14:09+00:00</published>
<link rel='alternate' type='text/html' href='http://trove.baserock.org/cgit/delta/ruby.git/commit/?id=53e8589c69d1345235d9f02ecbcf6aa32fa9d39c'/>
<id>53e8589c69d1345235d9f02ecbcf6aa32fa9d39c</id>
<content type='text'>
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
</pre>
</div>
</content>
</entry>
<entry>
<title>Removed duplicate file</title>
<updated>2019-11-11T06:57:21+00:00</updated>
<author>
<name>Nobuyoshi Nakada</name>
<email>nobu@ruby-lang.org</email>
</author>
<published>2019-11-11T06:56:59+00:00</published>
<link rel='alternate' type='text/html' href='http://trove.baserock.org/cgit/delta/ruby.git/commit/?id=65f7e3156f66bb4eba944c8ad2a463b9452b1a29'/>
<id>65f7e3156f66bb4eba944c8ad2a463b9452b1a29</id>
<content type='text'>
"./tests/test_helper.rb" and "tests/test_helper.rb" in `s.files`
are same.
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
"./tests/test_helper.rb" and "tests/test_helper.rb" in `s.files`
are same.
</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='http://trove.baserock.org/cgit/delta/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='http://trove.baserock.org/cgit/delta/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='http://trove.baserock.org/cgit/delta/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='http://trove.baserock.org/cgit/delta/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='http://trove.baserock.org/cgit/delta/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>
<entry>
<title>[flori/json] Fixed unexpected illegal/malformed utf-8 error</title>
<updated>2019-10-14T10:54:48+00:00</updated>
<author>
<name>Nobuyoshi Nakada</name>
<email>nobu@ruby-lang.org</email>
</author>
<published>2019-10-14T10:13:20+00:00</published>
<link rel='alternate' type='text/html' href='http://trove.baserock.org/cgit/delta/ruby.git/commit/?id=2003755a2c491fd81496308cad97ce6304c51fe8'/>
<id>2003755a2c491fd81496308cad97ce6304c51fe8</id>
<content type='text'>
flori/json@c34d01ff6a18dac04a90b2e0f820cdb1d5c7e1b2 does not
consider US-ASCII compatible but non-UTF-8 encodings, and causes
an error in RDoc tests.

https://github.com/flori/json/commit/4f471bf590
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
flori/json@c34d01ff6a18dac04a90b2e0f820cdb1d5c7e1b2 does not
consider US-ASCII compatible but non-UTF-8 encodings, and causes
an error in RDoc tests.

https://github.com/flori/json/commit/4f471bf590
</pre>
</div>
</content>
</entry>
<entry>
<title>[flori/json] Convert string encoding to UTF-8 only when needed</title>
<updated>2019-10-14T10:54:48+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://trove.baserock.org/cgit/delta/ruby.git/commit/?id=d7fa7e2c860430a3dfa1b08be96734925b6c81d8'/>
<id>d7fa7e2c860430a3dfa1b08be96734925b6c81d8</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
```

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

https://github.com/flori/json/commit/c34d01ff6a
</pre>
</div>
</content>
</entry>
<entry>
<title>[flori/json] Convert String encoding using `rb_str_encode()`</title>
<updated>2019-10-14T10:54:48+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://trove.baserock.org/cgit/delta/ruby.git/commit/?id=40724d7d10e9902fcdc4149326acbfe4dd95d3c7'/>
<id>40724d7d10e9902fcdc4149326acbfe4dd95d3c7</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
```

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

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