summaryrefslogtreecommitdiff
path: root/ext/json/ext/generator
Commit message (Collapse)AuthorAgeFilesLines
* Add an option to escape forward slash characterJean Boussier2020-07-042-7/+53
| | | | | | | | | | | | | | | | Squashed commit of the following: commit 26d181059989279a79c433cedcd893b4f52e42ee Author: Francois Chagnon <francois.chagnon@jadedpixel.com> Date: Tue Sep 15 21:17:34 2015 +0000 add config options for escape_slash commit fa282334051b16df91ca097dd7304b46f3bc7719 Author: Francois Chagnon <francois.chagnon@jadedpixel.com> Date: Mon Feb 9 21:09:33 2015 +0000 add forward slash to escape character
* Typo fixMarc-Andre Lafortune2020-06-301-1/+1
|
* Merge pull request #349 from zverok/nodocSHIBATA Hiroshi2019-12-291-0/+70
|\ | | | | Add :nodoc: for GeneratorMethods
| * Add :nodoc: for GeneratorMethodszverok2018-03-081-0/+70
| |
* | Add `GC.compact` again.tenderlove2019-10-311-0/+2
| | | | | | | | | | | | 🙏 git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@67620 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* | Suppress uninitialized instance variable warningsNobuyoshi Nakada2019-10-311-1/+1
| |
* | [flori/json] Fixed unexpected illegal/malformed utf-8 errorNobuyoshi Nakada2019-10-311-1/+10
| | | | | | | | | | | | | | | | 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
* | Remove unused constant.Aaron Patterson2019-10-311-2/+1
| | | | | | | | This constant isn't used, so lets remove it.
* | Look up constant instead of caching in a globalAaron Patterson2019-10-311-6/+3
| | | | | | | | | | The global can go bad if the compactor runs, so we need to look up the constant instead of caching it in a global.
* | Merge pull request #367 from sho-h/add-ascii_only-documentFlorian Frank2019-07-131-0/+2
|\ \ | | | | | | Add ascii_only option to JSON::Ext::Generator::State.new.
| * | Add ascii_only option to JSON::Ext::Generator::State.new.Sho Hashimoto2019-01-081-0/+2
| |/
* | Merge branch 'master' of github.com:flori/jsonFlorian Frank2019-04-291-1/+2
|\ \
| * \ Merge pull request #366 from sho-h/fix-ascii_only-documentFlorian Frank2019-02-211-1/+1
| |\ \ | | | | | | | | fix JSON::Generator::State#ascii_only? document same as lib/json/pure/generator.rb.
| | * | fix JSON::Generator::State#ascii_only? document same as ↵Sho Hashimoto2019-01-081-1/+1
| | |/ | | | | | | | | | lib/json/pure/generator.rb.
| * | Add some missing ruby 2.6 changesFlorian Frank2019-02-211-0/+1
| |/
* | Does not check whether illegal utf-8 if string has ascii only.Watson2019-04-291-8/+12
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | ## 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 << { :string => "x" * 100, :utf8 => "あ" * 100 } end Benchmark.ips do |x| x.report "json" do |iter| count = 0 while count < iter JSON.generate(obj) count += 1 end end end ```
* | Convert string encoding to UTF-8 only when neededWatson2019-04-291-1/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | ## 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 << { "id" => i, :age => 42, } end Benchmark.ips do |x| x.report "json" do |iter| count = 0 while count < iter JSON.generate(obj) count += 1 end end end ```
* | Convert String encoding using `rb_str_encode()`Watson2019-04-291-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | `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 << { "id" => i, :age => 42, } end Benchmark.ips do |x| x.report "json" do |iter| count = 0 while count < iter JSON.generate(obj) count += 1 end end end ```
* | Add shortcut converting to StringWatson2019-04-291-2/+9
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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 << { "id" => i, :age => 42, } end Benchmark.ips do |x| x.report "json" do |iter| count = 0 while count < iter JSON.generate(obj) count += 1 end end end ```
* | Convert Hash object using rb_hash_foreach()Watson2019-04-291-22/+55
|/ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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 << { "id" => i, :age => 42, } end Benchmark.ips do |x| x.report "json" do |iter| count = 0 while count < iter JSON.generate(obj) count += 1 end end end ```
* Fix arbitrary heap exposure problemFlorian Frank2017-04-182-7/+6
|
* Suppress a warningNobuyoshi Nakada2016-07-081-0/+1
| | | Suppress a unused-but-set-variable warning by gcc.
* RB_GC_GUARD to protect from premature GCPete Johns2016-07-011-0/+1
| | | | https://github.com/ruby/ruby/blob/trunk/doc/extension.rdoc#appendix-e-rb_gc_guard-to-protect-from-premature-gc
* Adapt to ruby integer unificationFlorian Frank2016-06-212-3/+43
|
* Remove quirks modeFlorian Frank2016-06-022-34/+1
|
* Merge branch 'v1.8'Florian Frank2016-02-251-1/+1
|\
| * Avoid system stack errorFlorian Frank2016-02-251-1/+1
| |
* | Remove generate restriction for […]/{…}Florian Frank2015-06-131-18/+0
|/
* generator.c: allocate structs with wrappernobu2015-05-282-11/+5
| | | | | | | | * ext/json/ext/generator/generator.c (cState_s_allocate): allocate structs with making new wrapper objects and get rid of potential memory leak. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@50661 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* use ZALLOC if it can be used, and defined ZALLOC macro.SHIBATA Hiroshi2015-02-122-2/+10
|
* Use space_before as documented in the generatorMichael Mac-Vicar2015-01-091-0/+1
| | | | | This option was already documented but not implemented, allows setting the separator used before the ":" during generation.
* Fall back to Data_* wrappers on ancient rubiesFlorian Frank2015-01-022-0/+8
|
* Merge branch 'ruby-2.2' of https://github.com/zzak/json into zzak-ruby-2.2Florian Frank2015-01-023-22/+42
|\ | | | | | | | | | | | | Conflicts: .travis.yml json.gemspec json_pure.gemspec
| * RUBY_TYPED_FREE_IMMEDIATELY isn't always availableZachary Scott2014-12-271-0/+2
| |
| * Use ALLOC and MEMZERO instead of ZALLOCZachary Scott2014-12-261-1/+2
| |
| * Revert part of "Sync with trunk"Zachary Scott2014-12-261-20/+0
| | | | | | | | This partially reverts commit 18b3000.
| * Sync with trunkZachary Scott2014-12-254-35/+72
| |
| * - Pass over generator.c for grammar fixes.Vipul A M2014-07-032-11/+11
| | | | | | | | - Typo fixes across json ext
* | Fix documentation wordingFlorian Frank2014-07-032-11/+11
|/
* Suppress warning: -Wchar-subscriptsNARUSE, Yui2013-05-081-2/+2
| | | | | | On some platforms char is signed char and giving signed char to isspace(int c) can cause unexpected behavior. To avoid such situation, it should cast as unsigned char.
* Validate UTF-8 strings.NARUSE, Yui2013-02-221-1/+12
| | | | | Raise JSON::GeneratorError on converting Ruby UTF-8 string to JSON as to JSON ASCII does.
* Try to convert first with to_hash, then to_hFlorian Frank2013-02-211-4/+1
| | | | | | | | rb_convert_type doesn't return if conversion fails, so use rb_check_convert_type and the raise vi rb_convert_type. Make sure, that this behaviour is consisten across all generator implementations. Fixes https://github.com/flori/json/issues/162
* Remove useless assert, fbuffer_alloc cares alreadyFlorian Frank2013-02-041-1/+0
|
* Increase hash likeness of State objectsFlorian Frank2012-12-312-1/+44
|
* Remove unnecessary GET_STATE(self) to avoid an unused-but-set-variable ↵Shugo Maeda2012-12-131-1/+0
| | | | warning in gcc 4.6.
* Use len for return valuesFlorian Frank2012-11-291-10/+10
|\
| * fix some bugs in the C versions of State::configure and add the alias in the ↵John Shahid2012-11-231-5/+5
|/ | | | Java version.
* Increase default max_nesting to 100Erik Michaels-Ober2012-10-051-2/+2
| | | | See discussion at https://github.com/intridea/multi_json/pull/59.
* Avoid silly compiler warningFlorian Frank2012-08-171-1/+1
|
* Move ruby macros into fbuffer.hFlorian Frank2012-08-171-21/+0
|