aboutsummaryrefslogtreecommitdiffstats
path: root/enum.c
Commit message (Collapse)AuthorAgeFilesLines
* array.c, enum.c: change sum algorithmmrkn2016-12-061-6/+11
| | | | | | | | | | | | * array.c (rb_ary_sum): change the algorithm to Kahan-Babuska balancing summation to be more precise. [Feature #12871] [ruby-core:77771] * enum.c (sum_iter, enum_sum): ditto. * test_array.rb, test_enum.rb: add an assertion for the above change. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@57001 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* unstable sort [ci skip]nobu2016-10-131-0/+6
| | | | | | | | * array.c (rb_ary_sort_bang, rb_ary_sort, rb_ary_sort_by_bang): [DOC] describe that sort may not be stable. * enum.c (enum_sort, enum_sort_by): ditto. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@56413 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * enum.c: [DOC] Improve doc [ci-skip]marcandre2016-10-061-5/+9
| | | | git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@56360 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * enum.c: Add reduce/inject alias note.hsbt2016-10-061-0/+3
| | | | | | [fix GH-1400][ci skip] Patch by @getaaron git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@56355 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * enum.c: Make Enumerable#chunk with no block returnmarcandre2016-10-041-2/+2
| | | | | | an Enumerator [#2172] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@56342 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* fid typos [ci skip]nobu2016-09-241-2/+2
| | | | | | * fix typos, "a" before "Integer" to "an". [Fix GH-1438] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@56225 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* enum.c (enum_sort): prevent wasteful array duplicaionmrkn2016-08-201-1/+1
| | | | git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@55975 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* enum.c: [DOC] Enumerable#uniq [ci skip]nobu2016-07-201-0/+4
| | | | | | | * enum.c (enum_uniq): add rdoc, reference to Array#uniq. [Feature #11090] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@55715 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* enum.c: Enumerable#uniqnobu2016-07-201-0/+35
| | | | | | | * enum.c (enum_uniq): new method Enumerable#uniq. [Feature #11090] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@55709 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* exclude non-VALUE in memo from GCnobu2016-05-201-4/+5
| | | | | | | | | | | * internal.h (NEW_PARTIAL_MEMO_FOR): shrink buffer array not to mark non-VALUE fields. fix check_rvalue_consistency abort with RGENGC_CHECK_MODE=2. * internal.h (NEW_CMP_OPT_MEMO): exclude struct cmp_opt_data from the valid array range. * enum.c (slicewhen_i): exclude inverted too. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@55079 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* enum.c: fix declaration-after-statementnobu2016-05-181-1/+2
| | | | | | | * enum.c (sum_iter): workaround of mixed declarations and code. erred by -Werror=declaration-after-statement option. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@55043 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* Optimize each_sum for hashesmrkn2016-05-181-6/+33
| | | | | | | * enum.c (enum_sum, hash_sum, hash_sum_i, enum_sum_i, sum_iter): Optimize for hashes when each method isn't redefined. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@55041 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* Extract int_range_sum from enum_summrkn2016-05-181-16/+21
| | | | | | | * enum.c (enum_sum, int_range_sum): Extract int_range_sum from enum_sum. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@55040 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* Optimize enum_sum for a range from int to intmrkn2016-05-171-0/+25
| | | | | | | | | | | | | * enum.c (enum_sum): Optimize for a range from int to int. * test/ruby/test_enum.rb (test_range_sum): Move from test_range.rb, and add assertions for some conditions. * test/ruby/test_enum.rb (test_hash_sum): Move from test_hash.rb. * test/ruby/test_hash.rb, test/ruby/test_range.rb: Remove test_sum. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@55034 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* Write document of Enumerable#summrkn2016-05-171-0/+26
| | | | git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@55033 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* Implement Enumerable#summrkn2016-05-171-0/+148
| | | | | | | | | | | | * enum.c (enum_sum): Implement Enumerable#sum. * test/ruby/test_enum.rb (test_sum): Test sum for Enumerable. * test/ruby/test_hash.rb (test_sum): Test sum for Hash. * test/ruby/test_range.rb (test_sum): Test sum for Range. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@55032 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* Use Integer instead of Fixnum and Bignum.akr2016-05-171-2/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | * object.c, numeric.c, enum.c, ext/-test-/bignum/mul.c, lib/rexml/quickpath.rb, lib/rexml/text.rb, lib/rexml/xpath_parser.rb, lib/rubygems/specification.rb, lib/uri/generic.rb, bootstraptest/test_eval.rb, basictest/test.rb, test/-ext-/bignum/test_big2str.rb, test/-ext-/bignum/test_div.rb, test/-ext-/bignum/test_mul.rb, test/-ext-/bignum/test_str2big.rb, test/csv/test_data_converters.rb, test/date/test_date.rb, test/json/test_json_generate.rb, test/minitest/test_minitest_mock.rb, test/openssl/test_cipher.rb, test/rexml/test_jaxen.rb, test/ruby/test_array.rb, test/ruby/test_basicinstructions.rb, test/ruby/test_bignum.rb, test/ruby/test_case.rb, test/ruby/test_class.rb, test/ruby/test_complex.rb, test/ruby/test_enum.rb, test/ruby/test_eval.rb, test/ruby/test_iseq.rb, test/ruby/test_literal.rb, test/ruby/test_math.rb, test/ruby/test_module.rb, test/ruby/test_numeric.rb, test/ruby/test_range.rb, test/ruby/test_rational.rb, test/ruby/test_refinement.rb, test/ruby/test_rubyvm.rb, test/ruby/test_struct.rb, test/ruby/test_variable.rb, test/rubygems/test_gem_specification.rb, test/thread/test_queue.rb: Use Integer instead of Fixnum and Bignum. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@55029 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* enum.c: examples of Enumerable#detect [ci skip]nobu2016-05-051-0/+5
| | | | | | | | * enum.c (enum_find): [DOC] add more examples to the documentation of Enumerable#detect, to show that it equals to Enumerable#find. [Fix GH-1340] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@54925 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * array.c (rb_ary_sum): Array#sum is implemented.akr2016-04-131-40/+8
| | | | | | | | | | | | | Kahan's compensated summation algorithm for precise sum of float numbers is moved from ary_inject_op in enum.c. * enum.c (ary_inject_op): Don't specialize for float numbers. [ruby-core:74569] [Feature#12217] proposed by mrkn. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@54565 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * enum.c (ary_inject_op): put subtract operation out of if-clause.mrkn2016-03-231-4/+5
| | | | git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@54238 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * enum.c (ary_inject_op): Use Kahan's compensated summation algorithmmrkn2016-03-231-4/+11
| | | | | | for summing up float values. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@54237 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * enum.c (ary_inject_op): Implement the specialized code for sum ofakr2016-03-171-26/+40
| | | | | | | | float numbers. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@54162 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * array.c, enum.c: make rdoc format consistent.mame2016-03-171-7/+7
| | | | git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@54155 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * array.c (rb_ary_max, rb_ary_min): implement Array#max and min withmame2016-03-171-7/+17
| | | | | | | | | | arguments. replace super call with rb_nmin_run. * enum.c (nmin_run): exported (as rb_nmin_run). * internal.h: added a prototype for rb_nmin_run. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@54152 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * array.c (rb_ary_max, rb_ary_min): Array#max and Array#min added.mame2016-03-171-7/+0
| | | | | | | | | | | | | | | [Feature #12172] * internal.h (OPTIMIZED_CMP): moved from enum.c so that array.c can use it. * test/ruby/test_array.rb (test_max, test_min): tests for Array#max and Array#min. * test/ruby/test_enum.rb (test_max, test_min): revised a bit to test Enumerable#max and #min explicitly. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@54150 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * internal.c: struct cmp_opt_data added for refactoring out a datamame2016-03-171-17/+14
| | | | | | | | | | structure for CMP_OPTIMIZABLE * array.c (struct ary_sort_data): use struct cmp_opt_data. * enum.c (struct min_t, max_t, min_max_t): use struct cmp_opt_data. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@54149 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * enum.c (ary_inject_op): Extracted from enum_inject.akr2016-03-171-57/+67
| | | | git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@54148 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * enum.c (enum_inject): Implement the specialized code for sum ofakr2016-03-171-10/+38
| | | | | | | | | | | | integers including Bignums. * internal.h (rb_fix_plus): Declared to be usable from enum_inject. * numeric.c (rb_fix_plus): Defined. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@54147 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * enum.c (enum_inject): Consider redefinition of Fixnum#+.akr2016-03-151-1/+2
| | | | | | | | [ruby-dev:49510] [Bug#12178] Reported by usa. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@54122 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * enum.c (enum_inject): Implement the specialied code for :+ operatorakr2016-03-151-0/+11
| | | | | | | for Fixnums. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@54120 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * enum.c (enum_inject): Implement the specialized code for self is anakr2016-03-151-0/+24
| | | | | | | array and a symbol operator is given. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@54119 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* Rename parameter namenobu2016-01-291-2/+2
| | | | | | | * enum.c (enum_take_while, enum_drop_while): rename block parameter to obj, since they are generic objects. [Fix GH-1226] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@53686 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * enum.c (enum_min, enum_max): do the same optimization as r53454.shugo2016-01-071-50/+58
| | | | git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@53456 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * enum.c (enum_minmax): optimize object comparison inshugo2016-01-071-10/+27
| | | | | | Enumerable#minmax. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@53454 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * enum.c: fix a typo in documentation.hsbt2015-12-141-1/+1
| | | | | | | | | | | | [ci skip][fix GH-1140] Patch by @jutaz * io.c: ditto. * iseq.c: ditto. * numeric.c: ditto. * process.c: ditto. * string.c: ditto. * vm_trace.c: ditto. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@53105 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* add a comment.akr2015-10-041-1/+1
| | | | git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@52027 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * enum.c (nmin_filter): Fix limit value.akr2015-10-041-3/+3
| | | | | | | | | patch by Helder Pereira. [Bug #11471] [ruby-core:70477] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@52026 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* preserve encodings in error messagesnobu2015-09-281-2/+2
| | | | git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@51962 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * enum.c: added doc for Enumerable#ziphsbt2015-08-111-0/+4
| | | | | | | | [fix GH-985] Patch by @yui-knk * test/ruby/test_enum.rb: added tests for Enumerable#zip [fix GH-985] Patch @yui-knk git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@51526 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * Add test case for empty array and first method with args.hsbt2015-07-041-0/+1
| | | | | | Patch by @yui-knk [fix GH-955] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@51141 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* enum.c: remove volatile, use RB_GC_GUARDnormal2015-07-041-6/+12
| | | | | | | | | | | volatile appears unnecessary in most cases as the VALUEs are used as arguments of uninlined functions. Even worse, volatile can be insufficient in places where RB_GC_GUARD is necessary. * enum.c (zip_ary): remove volatile, use RB_GC_GUARD (zip_i): ditto git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@51139 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * Add test for Enumerable#none? [fix GH-950] Patch by @yui-knkhsbt2015-07-011-0/+1
| | | | git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@51083 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* enum.c (enum_minmax): simplify return value creationnormal2015-06-251-4/+2
| | | | | | | | | | | | | | No need to call three functions on success when one will do. This results in less LoC and smaller object code, too: text data bss dec hex filename 33860 0 296 34156 856c gcc/enum.o-before 33852 0 296 34148 8564 gcc/enum.o * enum.c (enum_minmax): simplify return value creation * test/ruby/test_enum.rb: test behavior on empty git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@51036 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * enum.c (enum_chunk_while): New method Enumerable#chunk_while.akr2015-06-141-0/+71
| | | | | | | | [ruby-core:67738] [Feature #10769] proposed by Tsuyoshi Sawada. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@50889 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* enum.c: [DOC] Fix typo [ci skip][Fix GH-904]gogotanaka2015-06-011-1/+1
| | | | | | Patch provided by @jwworth git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@50710 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * enum.c: fix a sample code. Patch by @eagletmthsbt2015-05-161-1/+1
| | | | | | [fix GH-901][ci skip] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@50508 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * enum.c (enum_grep_v, grep_i, grep_iter_i, Init_enum):sorah2015-05-141-3/+30
| | | | | | Implement Enumerable#grep_v. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@50491 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * enum.c (enum_to_a): revert r50457.glass2015-05-131-8/+1
| | | | | | | | it requires recursion check. then, it doesn't make performance improvement. [Bug #11130] [Feature #9118] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@50483 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * enum.c (enum_to_a): fix incompatibility introduced in r50457.glass2015-05-121-3/+3
| | | | | | | | [Bug #11130] * test/ruby/test_enum.rb: test for above. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@50477 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * enum.c (enum_to_a): Use size to set array capa when possible.glass2015-05-101-1/+8
| | | | | | | the patch is from HonoreDB <aweiner at mdsol.com>. [fix GH-444] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@50457 b2dd03c8-39d4-4d8f-98ff-823fe69b080e