Граф коммитов

244 Коммитов

Автор SHA1 Сообщение Дата
svn 483dcef8fb * expand tabs.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@65303 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-10-22 11:23:57 +00:00
knu 8717f0787d Set the size of a new enumerator created by Enumerator#each with arguments to nil
When each() takes arguments, it is never safe to assume that the iteration
would repeat the same number of times as with each() without any
argument.  Actually, there is no way to get the exact number, so the
size should be set to nil to denote that.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@65302 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-10-22 11:23:56 +00:00
stomar ee2416e33c enumerator.c: [DOC] small fix
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@65042 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-10-12 21:55:49 +00:00
nobu aefdd4e25f Lazy Enumerator reduce intermediate array creation
[ruby-core:87907] [Bug #14908] [Fix GH-1912]

From: Anmol Chopra <chopraanmol1@gmail.com>

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@64770 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-09-18 08:49:40 +00:00
kazu c0f62450bb [DOC] aseq.each always return self [ci skip]
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@64701 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-09-12 16:05:07 +00:00
mrkn 1595421ce0 [DOC] Add the documentation of ArithmeticSequence
[ci-skip]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@64696 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-09-12 08:36:48 +00:00
mrkn 11ff6569ea enumerator.c: Fix ArithmeticSequence for complex step
Make sure Enumerator::ArithmeticSequence#each to work well
for a complex step value.

This reverts commit ca47fb329a.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@64695 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-09-12 07:35:42 +00:00
mrkn ca47fb329a Revert "enumerator.c: Fix ArithmeticSequence for complex step"
This reverts commit 0a0f8238d0.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@64693 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-09-12 05:52:27 +00:00
mrkn 0a0f8238d0 enumerator.c: Fix ArithmeticSequence for complex step
Make sure Enumerator::ArithmeticSequence#each to work well
for a complex step value.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@64692 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-09-12 05:35:46 +00:00
nobu c1cc84187f enumerator.c: [DOC] Enumerator::Lazy#force [ci skip]
added documentation of Enumerator::Lazy#force, just to clarify that it
is an alias of an inherited method.  [ruby-core:88872] [Bug #15079]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@64645 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-09-05 20:40:49 +00:00
kazu 023537f883 Remove extra semicolon
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@64480 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-08-20 15:33:59 +00:00
nobu 7d6a26f2a1 Adding Enumerator::Lazy#uniq and Enumerator::Lazy#grep_v to proc chaining
[Feature #14994]

[Fix GH-1930]

From: Anmol Chopra <chopraanmol1@gmail.com>

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@64385 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-08-16 00:58:21 +00:00
nobu 2c195f64cf enumerator.c: id_lazy is no longer used since r38923
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@64384 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-08-16 00:13:47 +00:00
mrkn 33791cd092 enumerator.c: fix for non-integral argument for ArithmeticSequence#last
This fixes a bug of Enumerator::ArithmeticSequence#last in the case that
a non-integral argument is passed.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@64262 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-08-10 04:49:44 +00:00
mrkn 25a5227ab1 enumerator.c: undef new and allocate of ArithmeticSequence
Undefine new and allocate methods of Enumerator::ArithmeticSequence.

[ruby-core:82816] [Feature #13904]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@64256 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-08-09 13:18:08 +00:00
mrkn f15069338d enumerator.c: Introduce Enumerator::ArithmeticSequence
This commit introduces new core class Enumerator::ArithmeticSequence.
Enumerator::ArithmeticSequence is a subclass of Enumerator, and
represents a number generator of an arithmetic sequence.

After this commit, Numeric#step and Range#step without blocks
returned an ArithmeticSequence object instead of an Enumerator.

This class introduces the following incompatibilities:

- You can create a zero-step ArithmeticSequence,
  and its size is not ArgumentError, but Infinity.
- You can create a negative-step ArithmeticSequence from a range.

[ruby-core:82816] [Feature #13904]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@64205 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-08-06 09:08:28 +00:00
nobu 06af2865de enumerator.c: pretty kwags
* enumerator.c (append_method): pretty format for keyword
  arguments.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@62755 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-03-15 06:29:04 +00:00
nobu 0faf018624 Bug Fix Enumerator::Lazy#uniq state for multiple call
* enumerator.c (lazy_uniq_i): create new hash for each calls.
  [Fix GH-1820]

Currently

	2.5.0-preview1 :001 > arr = (0..100).lazy.uniq{|i| i % 10}
	 => #<Enumerator::Lazy: #<Enumerator::Lazy: 0..100>:uniq>
	2.5.0-preview1 :002 > arr.to_a
	 => [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]
	2.5.0-preview1 :003 > arr.to_a
	 => []

Expected

arr.to_a to always return same output

From: Anmol Chopra <anmolchopra@rocketbox.in>

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@62731 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-03-13 01:00:08 +00:00
eregon b1a8c64483 Add a new #filter alias for #select
* In Enumerable, Enumerator::Lazy, Array, Hash and Set
  [Feature #13784] [ruby-core:82285]
* Share specs for the various #select#select! methods and
  reuse them for #filter/#filter!.
* Add corresponding filter tests for select tests.
* Update NEWS.

[Fix GH-1824]

From: Alexander Patrick <adp90@case.edu>

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@62575 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-02-25 13:52:07 +00:00
normal 7e669f40be ruby/ruby.h: remove unnecessary exports from C-API
Needlessly exporting can reduce performance locally and increase
binary size.

Increasing the footprint of our C-API larger is also detrimental
to our development as it encourages tighter coupling with our
internals; making it harder for us to preserve compatibility.

If some parts of the core codebase needs access to globals,
internal.h should be used instead of anything in include/ruby/*.

"Urabe, Shyouhei" <shyouhei@ruby-lang.org> wrote:
> On Thu, Jan 18, 2018 at 7:33 PM, Eric Wong <normalperson@yhbt.net> wrote:
> > shyouhei@ruby-lang.org wrote:
> >>   https://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=revision&revision=61908
> >>
> >>     export rb_mFConst
> >
> > Why are we exporting all these and making the public C-API bigger?
> > If anything, we should make these static.  Thanks.
>
> No concrete reason, except they have already been externed in 2.5.
> These variables had lacked declarations so far, which resulted in their
> visibility to be that of extern. The commit is just confirming the status quo.
>
> I'm not against to turn them into static.

This reverts changes from r61910, r61909, r61908, r61907, and r61906.

* transcode.c (rb_eUndefinedConversionError): make static
  (rb_eInvalidByteSequenceError): ditto
  (rb_eConverterNotFoundError): ditto
* process.c (rb_mProcGID, rb_mProcUid, rb_mProcID_Syscall): ditto
* file.c (rb_mFConst): ditto
* error.c (rb_mWarning, rb_cWarningBuffer): ditto
* enumerator.c (rb_cLazy): ditto
  [Misc #14381]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@62029 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-01-24 21:07:14 +00:00
shyouhei 3ca0948f68 INFINITY is float. That of double is HUGE_VAL.
It seems HUGE_VAL is already used. Why not eliminate INTINITY.
NAN is also float. That of double is called nan(). This is also
fixed.

Signed-off-by: Urabe, Shyouhei <shyouhei@ruby-lang.org>

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@61938 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-01-19 01:45:36 +00:00
normal 4c0c299964 use predefined ids in a few more places
Saves a little space on x86:

   text	   data	    bss	    dec	    hex	filename
3684110	  11968	  34240	3730318	 38eb8e	ruby.before
3684086	  11968	  34240	3730294	 38eb76	ruby.after

* enumerator.c: include id.h, define aliases
  (Init_Enumeerator): remove unnecessary rb_intern calls
* gc.c (should_be_callable): use idCall
* vm.c (Init_VM): ditto

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@61704 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-01-09 02:45:03 +00:00
nobu 20685cdc85 Get rid of shadowing local variables
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@60204 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-10-18 04:35:25 +00:00
nobu 51982c8139 enumerator.c: fix nested maps
* enumerator.c (lazy_map_proc, lazy_grep_iter_proc): marks values
  returned by blocks are not packed in the case of nested maps, so
  that the result will be same as non-lazy version.  based on the
  patch by akihikodaki (Akihiko Odaki) at [ruby-core:81638],
  without GCC extension.  [Bug#13648]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@59056 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-06-10 10:26:32 +00:00
akr 7c7444bcd3 Enumerator::Lazy#chunk_while defined.
* enumerator.c (InitVM_Enumerator): Enumerator::Lazy#chunk_while
  defined.  [Fix GH-1186]
  https://github.com/ruby/ruby/pull/1186



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@56607 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2016-11-05 15:46:48 +00:00
nobu 856afbef61 enumerator.c: lazy enum improvement
* enumerator.c (lazy_init_yielder): directly call stored functions.
  [Feature #6183]
* enumerator.c (lazy_add_method): create lazy enumerator which
  uses lazy_init_yielder().

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@56185 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2016-09-19 01:36:56 +00:00
nobu c463366dfd rb_funcallv
* *.c: rename rb_funcall2 to rb_funcallv, except for extensions
  which are/will be/may be gems.  [Fix GH-1406]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@55773 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2016-07-29 11:57:14 +00:00
nobu 6882b35460 enumerator.c: Enumerator::Lazy#uniq
* enumerator.c (lazy_uniq): new method Enumerator::Lazy#uniq.
  [Feature #11090]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@55710 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2016-07-20 08:44:08 +00:00
nobu 5987e6a50b enumerator.c: use ALLOCV
* enumerator.c (lazy_init_iterator): use ALLOCV instead of tmp
  array.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@53132 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-12-15 15:32:28 +00:00
ko1 2f5b8f0529 * *.c (*_memsize): do not check ptr.
NULL checking is finished Before call of memsize functions.
  See r52979.




git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@52986 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-12-09 00:38:32 +00:00
nobu 7d0b7fb4cf enumerator.c: lazy_grep_v
* enumerator.c (lazy_grep_v): add Enumerator::Lazy#grep_v as well
  as Enumerable, to enumerate lazily.
  [ruby-core:71845] [Feature #11773]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@52943 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-12-08 07:23:43 +00:00
nobu 4191a6b90d preserve encodings in error messages
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@51962 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-09-28 02:40:46 +00:00
ko1 08f3cfb585 * internal.h: use T_IMEMO to represent `struct MEMO' value.
memo->v1 and memo->v2 is WB protected values.
  So use MEMO_V1/V2_SET() macros to set these values.
  memo->u3 is ambiguous (sometimes a VALUE, sometimes an integer
  value), so use gc_mark_maybe() in gc.c to mark it.
  Rename NEW_MEMO() to MEMO_NEW().
  Move MEMO_FOR and NEW_MEMO_FOF macros from node.h.
  Export a rb_imemo_new() function for ext/ripper.
* node.h: remove NODE_MEMO.
* enum.c: catch up these change.
* enumerator.c: ditto.
* load.c: ditto.
* ext/objspace/objspace.c (count_nodes): ditto.
* gc.c (gc_mark_children): mark imemo_memo type.
* parse.y (new_args_gen): use T_IMEMO.
  (I'm not sure it is working correctly...)



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@49942 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-03-11 23:13:01 +00:00
ko1 97e21517a3 * internal.h: define struct MEMO.
* enum.c: use MEMO.
* enumerator.c: ditto.
* load.c: ditto.
* node.h: return (struct MEMO *) pointer.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@49928 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-03-11 00:20:45 +00:00
nobu e580a631be use 0 for reserved
use 0 for rb_data_type_t::reserved instead of NULL, since its type
may be changed in the future and possibly not a pointer type.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@48662 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-12-01 06:38:04 +00:00
akr 7cd76ab0c5 * internal.h: Include ruby.h and ruby/encoding.h to be
includable without prior inclusion.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@48447 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-11-15 11:49:06 +00:00
akr cc659d2f1b * enum.c (enum_slice_when): New method: Enumerable#slice_when.
(slicewhen_i): New function.
  (slicewhen_ii): New function.

* enumerator.c (InitVM_Enumerator): New method:
  Enumerator::Lazy#slice_when.

  [ruby-core:62499] [Feature #9826]



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@47652 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-09-20 06:52:29 +00:00
nobu 95d1b61a14 symbols instead of IDs
* encoding.c (rb_enc_get_index): deal with symbols instead of IDs
  to get rid of inadvertent pin-downs.

* enum.c (chunk_ii): ditto.

* enumerator.c (append_method): ditto.

* iseq.c (iseq_load): ditto.

* marshal.c (w_symbol, r_symlink, r_symreal, r_symbol): ditto.

* signal.c (trap_handler): ditto.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@46988 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-07-28 08:15:42 +00:00
nobu 876bfc6b4e Init functions don't need ID caches
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@46663 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-07-03 03:38:10 +00:00
nobu e99ee55abc constify parameters
* include/ruby/intern.h: constify `argv` parameters.

* include/ruby/ruby.h: ditto.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@46459 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-06-18 06:16:39 +00:00
zzak a563664e06 * enumerator.c: [DOC] Fix example to show Enumerator#peek behavior
Patch by Erik Hollembeak [Bug #9814] [ci skip]


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@46099 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-05-25 03:00:17 +00:00
nobu abfa2b6c7e enumerator.c: adjust style [ci skip]
* enumerator.c (yielder_yield_push): Insert a break after the
  method return value.  [fix GH-617]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@46071 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-05-24 06:05:35 +00:00
akr ddd155842f * enum.c: Enumerable#slice_after implemented.
* enumerator.c: Enumerator::Lazy#slice_after implemented.

  Requested by Tsuyoshi Sawada.  [ruby-core:58123] [Feature #9071]



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@45981 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-05-18 00:06:05 +00:00
ko1 57e557908a * enumerator.c (enumerator_block_call): use PARRAY_CONST_PTR()
instead of RARRAY_PTR().
* io.c (rb_io_s_popen): ditto.
* numeric.c (num_step_size): ditto.
* vm_eval.c (rb_apply): ditto.
* vm_eval.c (rb_eval_cmd): ditto.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@45353 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-03-17 04:20:16 +00:00
nobu 520f0fec95 enumerator.c: should not store local variable address
* enumerator.c (enumerator_with_index): should not store local variable
  address to memoise the arguments.  it is invalidated after the return.
  [ruby-core:58692] [Bug #9178]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@43929 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-11-30 07:25:17 +00:00
nobu 7566c49068 ruby/ruby.h: RB_BLOCK_CALL_FUNC_ARGLIST
* include/ruby/ruby.h (RB_BLOCK_CALL_FUNC_ARGLIST): for declaration
  argument list of rb_block_call_func.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@43910 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-11-29 07:59:14 +00:00
nobu 9f45081627 ruby/ruby.h: add blockarg to rb_block_call_func
* include/ruby/ruby.h (rb_block_call_func): add blockarg.  block
  function can take block argument, e.g., proc {|&blockarg| ...}.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@43907 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-11-29 02:26:48 +00:00
glass eb86296497 * enumerator.c (append_method): use RARRAY_CONST_PTR().
* enumerator.c (lazy_init_iterator): ditto.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@43578 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-11-08 01:52:07 +00:00
ko1 c5e08b764e * add RUBY_TYPED_FREE_IMMEDIATELY to data types which only use
safe functions during garbage collection such as xfree().
  On default, T_DATA objects are freed at same points as fianlizers.
  This approach protects issues such as reported by [ruby-dev:35578].
  However, freeing T_DATA objects immediately helps heap usage.
  Most of T_DATA (in other words, most of dfree functions) are safe.
  However, we turned off RUBY_TYPED_FREE_IMMEDIATELY by default
  for safety.
* cont.c: ditto.
* dir.c: ditto.
* encoding.c: ditto.
* enumerator.c: ditto.
* error.c: ditto.
* file.c: ditto.
* gc.c: ditto.
* io.c: ditto.
* iseq.c: ditto.
* marshal.c: ditto.
* parse.y: ditto.
* proc.c: ditto.
* process.c: ditto.
* random.c: ditto.
* thread.c: ditto.
* time.c: ditto.
* transcode.c: ditto.
* variable.c: ditto.
* vm.c: ditto.
* vm_backtrace.c: ditto.
* vm_trace.c: ditto.
* ext/bigdecimal/bigdecimal.c: ditto.
* ext/objspace/objspace.c: ditto.
* ext/stringio/stringio.c: ditto.
* ext/strscan/strscan.c: ditto.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@43466 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-10-29 11:16:54 +00:00
ko1 dc626dbab3 * include/ruby/ruby.h: rename RARRAY_RAWPTR() to RARRAY_CONST_PTR().
RARRAY_RAWPTR(ary) returns (const VALUE *) type pointer and
  usecase of this macro is not acquire raw pointer, but acquire
  read-only pointer. So we rename to better name.
  RSTRUCT_RAWPTR() is also renamed to RSTRUCT_CONST_PTR()
  (I expect that nobody use it).
* array.c, compile.c, cont.c, enumerator.c, gc.c, proc.c, random.c,
  string.c, struct.c, thread.c, vm_eval.c, vm_insnhelper.c:
  catch up this change.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@43043 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-09-25 08:24:34 +00:00