| Commit message (Collapse) | Author | Age | Files | Lines |
... | |
|\ \ \ |
|
| |/ / |
|
| |\ \
| | | |
| | | | |
README.md typo fix
|
| |/ / |
|
|/ / |
|
|\ \ |
|
| |\ \
| | | |
| | | | |
Fix inconsistency usage for assertion methods
|
| |/ / |
|
| |\ \
| | | |
| | | | |
Suppress a warning
|
| | | |
| | | |
| | | | |
Suppress a unused-but-set-variable warning by gcc.
|
| |\ \ \
| | |/ /
| |/| | |
Fix typo "improvemed" => "improved"
|
| |/ / |
|
| |\ \
| | | |
| | | | |
(README.md) Now complies to newest JSON RFC 7159.
|
| |/ /
| | |
| | |
| | | |
7159.](https://github.com/chottoda/json/blob/master/CHANGES.md#2015-09-11-200)
|
| | | |
|
| | | |
|
|/ / |
|
| | |
|
| | |
|
| | |
|
| |
| |
| |
| | |
See flori/json#287
|
| | |
|
| | |
|
| |
| |
| |
| | |
https://github.com/ruby/ruby/blob/trunk/doc/extension.rdoc#appendix-e-rb_gc_guard-to-protect-from-premature-gc
|
| | |
|
| | |
|
| | |
|
| | |
|
| | |
|
|\ \ |
|
| | | |
|
| | | |
|
| | |
| | |
| | |
| | | |
When you change this to true, you may need to add more tests.
|
| | |
| | |
| | |
| | |
| | | |
Use ':' in rb_scan_args to get optional hash, which available
since ruby 2.1.
|
| | |
| | |
| | |
| | | |
Raise with messages in UTF-8 encoding.
|
| | |
| | |
| | |
| | | |
Use rb_encoding functions to convert encodings.
|
| | |
| | |
| | |
| | | |
StringValue does the conversion.
|
| | |
| | |
| | |
| | |
| | | |
Use `enum` instead of `static const int` to get rid of
unused-const-variable warnings.
|
| | | |
|
| | |
| | |
| | |
| | |
| | | |
Remove useless overriding methods, [] and []=, which are same as
OpenStruct.
|
| | | |
|
| | | |
|
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | | |
The parser uses `rb_str_buf_new` to allocate new strings.
`rb_str_buf_new` [has a minimum size of 128 and is not an embedded
string](https://github.com/ruby/ruby/blob/9949407fd90c1c5bfe332141c75db995a9b867aa/string.c#L1119-L1135). This causes applications that parse JS to allocate extra memory when parsing short strings.
For a real-world example, we can use the mime-types gem. The mime-types
gem stores all mime types inside a JSON file and parses them when you
require the gem.
Here is a sample program:
```ruby
require 'objspace'
require 'mime-types'
GC.start
GC.start
p ObjectSpace.memsize_of_all String
```
The example program loads the mime-types gem and outputs the total space
used by all strings. Here are the results of the program before and
after this patch:
** Before **
```
[aaron@TC json (memuse)]$ ruby test.rb
5497494
[aaron@TC json (memuse)]$
```
** After **
```
[aaron@TC json (memuse)]$ ruby -I lib:ext test.rb
3335862
[aaron@TC json (memuse)]$
```
This change results in a ~40% reduction of memory use for strings in the
mime-types gem.
Thanks @matthewd for finding the problem, and @nobu for the patch!
|
|\ \ \
| |/ /
|/| | |
|
| |\ \
| | | |
| | | | |
resize strings after parsing
|
| | | | |
|
| |/ /
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | | |
The parser uses `rb_str_buf_new` to allocate new strings.
`rb_str_buf_new` [has a minimum size of 128 and is not an embedded
string](https://github.com/ruby/ruby/blob/9949407fd90c1c5bfe332141c75db995a9b867aa/string.c#L1119-L1135). This causes applications that parse JS to allocate extra memory when parsing short strings.
For a real-world example, we can use the mime-types gem. The mime-types
gem stores all mime types inside a JSON file and parses them when you
require the gem.
Here is a sample program:
```ruby
require 'objspace'
require 'mime-types'
GC.start
GC.start
p ObjectSpace.memsize_of_all String
```
The example program loads the mime-types gem and outputs the total space
used by all strings. Here are the results of the program before and
after this patch:
** Before **
```
[aaron@TC json (memuse)]$ ruby test.rb
5497494
[aaron@TC json (memuse)]$
```
** After **
```
[aaron@TC json (memuse)]$ ruby -I lib:ext test.rb
3335862
[aaron@TC json (memuse)]$
```
This change results in a ~40% reduction of memory use for strings in the
mime-types gem.
Thanks @matthewd for finding the problem, and @nobu for the patch!
|
| | | |
|
| | | |
|
|/ / |
|