[#4654] signleton_methods / methods / public_methods - weirdness? — Johan Holmberg <holmberg@...>
[#4666] Getting a hex representation for a Numeric — "Zev Blut" <rubyzbibd@...>
Hello,
[#4670] ruby 1.8.3 preview1 plan — Yukihiro Matsumoto <matz@...>
Hi,
[#4690] test failures for stable-snapshot 09/04/2005 — noreply@...
Bugs item #1762, was opened at 10-04-2005 20:46
Hello.
[#4709] BNF-like grammar specified DIRECTLY in Ruby — Eric Mahurin <eric_mahurin@...>
Hello everybody,
[#4712] Segfault in zlib? — Nathaniel Talbott <ntalbott@...>
I'm using rubyzip (latest gem version) and zlib (1.2.2) to do a bunch
[#4736] Trivial speedup in Array#zip — Mauricio Fern疣dez <batsman.geo@...>
[#4745] Win32: Ruby & APR; build problems for Ruby Subversion SWIG bindings — Erik Huelsmann <ehuels@...>
Having taken upon me the task to provide a Windows build for
On 4/20/05, Erik Huelsmann <ehuels@gmail.com> wrote:
Hi Austin,
Hi,
On 4/24/05, nobu.nokada@softhome.net <nobu.nokada@softhome.net> wrote:
Hi,
> > > Ruby is just using AC_TYPE_UID_T. So, using typedef for them,
Hi,
On 4/26/05, nobu.nokada@softhome.net <nobu.nokada@softhome.net> wrote:
As promised, I attached a patch to eliminate the compile problems
Hi,
Thanks for the quick response!
Hi,
On 5/14/05, nobu.nokada@softhome.net <nobu.nokada@softhome.net> wrote:
[#4751] Illegal regexp causes segfault — Andrew Walrond <andrew@...>
irb(main):058:0> a = /\[([^]]*)\]/
Andrew Walrond, April 22:
In article <200504221210.38231.andrew@walrond.org>,
>>>>> "T" == Tanaka Akira <akr@m17n.org> writes:
[#4774] enhanced $0 modification — Evan Webb <evanwebb@...>
The attached patch allows for ruby to use more of the available stack
Hi,
[#4775] profiler.rb Schroedinbug — C Erler <erlercw@...>
A ruby program with the single instruction "require 'profile'"
>A ruby program with the single instruction "require 'profile'"
[#4807] Re: -Wall — Vincent Isambart <vincent.isambart@...>
> Why does ruby build without -Wall in CFLAGS by default? -Wall can help to
[#4815] Re: -Wall — nobu.nokada@...
Hi,
Re: [PATCH] Trivial speedup in Array#zip
>diff -ru ruby.orig/array.c ruby/array.c
>--- ruby.orig/array.c 2005-04-20 02:09:10.000000000 +0200
>+++ ruby/array.c 2005-04-20 02:22:22.000000000 +0200
>@@ -2074,16 +2074,31 @@
> argv[i] = to_ary(argv[i]);
> }
> if (rb_block_given_p()) {
>- for (i=0; i<RARRAY(ary)->len; i++) {
>+ if (rb_multiple_asgn_in_block_p()) {
> VALUE tmp = rb_ary_new2(argc+1);
>
>- rb_ary_push(tmp, rb_ary_elt(ary, i));
>- for (j=0; j<argc; j++) {
>- rb_ary_push(tmp, rb_ary_elt(argv[j], i));
>+ RARRAY(tmp)->len = argc + 1;
>+ for (i=0; i<RARRAY(ary)->len; i++) {
>+ RARRAY(tmp)->ptr[0] = RARRAY(ary)->ptr[i];
>+ for (j=0; j<argc; j++) {
>+ RARRAY(tmp)->ptr[1+j] = rb_ary_elt(argv[j], i);
>+ }
>+ rb_yield(tmp);
> }
>- rb_yield(tmp);
>+ return Qnil;
>+ }
>+ else {
>+ for (i=0; i<RARRAY(ary)->len; i++) {
>+ VALUE tmp = rb_ary_new2(argc+1);
>+
>+ rb_ary_push(tmp, rb_ary_elt(ary, i));
>+ for (j=0; j<argc; j++) {
>+ rb_ary_push(tmp, rb_ary_elt(argv[j], i));
>+ }
>+ rb_yield(tmp);
>+ }
>+ return Qnil;
> }
>- return Qnil;
> }
> len = RARRAY(ary)->len;
> result = rb_ary_new2(len);
It doesn't look nice both optimized code (masign) and non optimized code (array) coexist.
Instead, is this possible? (This is just an idea, though)
1. define some internal array object. this object never be passed to ruby world. (ex: InternalArray)
2. implement Array#zip using this.
if (rb_block_given_p()) {
VALUE temp = rb_internal_array_new2(argc+1);
...
rb_yield(temp); /* If {|a| ... }, convert InternalArray to Array.
If {|a,b,c| ... }, pass each element of InternalArray */
}
3. implement rb_yield like above.
Maybe Value object can be used as internal array. (this doesn't work as expected now. just an idea)
static VALUE
rb_ary_zip(argc, argv, ary)
int argc;
VALUE *argv;
VALUE ary;
{
int i, j;
VALUE result = Qnil;
VALUE tmp;
for (i=0; i<argc; i++) {
argv[i] = to_a(argv[i]);
}
if (!rb_block_given_p()) {
result = rb_ary_new2(RARRAY(ary)->len);
}
tmp = rb_values_new2(argc+1, 0);
RARRAY(tmp)->len = argc+1;
for (i=0; i<RARRAY(ary)->len; i++) {
RARRAY(tmp)->ptr[0] = rb_ary_elt(ary, i);
for (j=0; j<argc; j++) {
RARRAY(tmp)->ptr[j+1] = rb_ary_elt(argv[j], i);
}
if (!NIL_P(result))
rb_ary_push(result, to_a(tmp)); /* I hope this convert Value to new Array */
else
rb_yield(tmp); /* I hope this works as described above */
}
return result;
}
//////////////////
Anyway, current code already looks dup....
Fotunately, I cannot see speed down on this code.
Index: array.c
===================================================================
RCS file: /src/ruby/array.c,v
retrieving revision 1.171
diff -u -w -b -p -r1.171 array.c
--- array.c 4 Mar 2005 06:47:45 -0000 1.171
+++ array.c 20 Apr 2005 09:17:20 -0000
@@ -2108,34 +2108,25 @@ rb_ary_zip(argc, argv, ary)
VALUE ary;
{
int i, j;
- long len;
- VALUE result;
+ VALUE result = Qnil;
for (i=0; i<argc; i++) {
argv[i] = to_a(argv[i]);
}
- if (rb_block_given_p()) {
- for (i=0; i<RARRAY(ary)->len; i++) {
- VALUE tmp = rb_ary_new2(argc+1);
-
- rb_ary_push(tmp, rb_ary_elt(ary, i));
- for (j=0; j<argc; j++) {
- rb_ary_push(tmp, rb_ary_elt(argv[j], i));
+ if (!rb_block_given_p()) {
+ result = rb_ary_new2(RARRAY(ary)->len);
}
- rb_yield(tmp);
- }
- return Qnil;
- }
- len = RARRAY(ary)->len;
- result = rb_ary_new2(len);
- for (i=0; i<len; i++) {
+ for (i=0; i<RARRAY(ary)->len; i++) {
VALUE tmp = rb_ary_new2(argc+1);
rb_ary_push(tmp, rb_ary_elt(ary, i));
for (j=0; j<argc; j++) {
rb_ary_push(tmp, rb_ary_elt(argv[j], i));
}
+ if (!NIL_P(result))
rb_ary_push(result, tmp);
+ else
+ rb_yield(tmp);
}
return result;
}