[#71815] [Ruby trunk - Bug #11768] [Open] Add a polymorphic inline cache — tenderlove@...
Issue #11768 has been reported by Aaron Patterson.
tenderlove@ruby-lang.org wrote:
On Thu, Dec 03, 2015 at 10:51:08PM +0000, Eric Wong wrote:
Aaron Patterson <tenderlove@ruby-lang.org> wrote:
[#71818] [Ruby trunk - Feature #11769] [Open] optimize case / when for `nil` — tenderlove@...
Issue #11769 has been reported by Aaron Patterson.
tenderlove@ruby-lang.org wrote:
[#71931] [Ruby trunk - Feature #11786] [Open] [PATCH] micro-optimize case dispatch even harder — normalperson@...
Issue #11786 has been reported by Eric Wong.
Oops, I forgot to free the table when iseq is destroyed :x
On 2015/12/08 12:43, Eric Wong wrote:
SASADA Koichi <ko1@atdot.net> wrote:
On 2015/12/08 13:53, Eric Wong wrote:
[#72028] [Ruby trunk - Feature #11405] [Assigned] [PATCH] hash.c: minor speedups to int/fixnum keys — mame@...
Issue #11405 has been updated by Yusuke Endoh.
mame@ruby-lang.org wrote:
[#72045] Ruby 2.3.0-preview2 Released — "NARUSE, Yui" <naruse@...>
We are pleased to announce the release of Ruby 2.3.0-preview2.
Please add your optimizations before RC1.
SASADA Koichi <ko1@atdot.net> wrote:
On 2015/12/11 18:06, Eric Wong wrote:
SASADA Koichi <ko1@atdot.net> wrote:
[#72069] [Ruby trunk - Feature #11405] [PATCH] hash.c: minor speedups to int/fixnum keys — mame@...
Issue #11405 has been updated by Yusuke Endoh.
[#72115] Re: [ruby-cvs:60264] duerst:r53112 (trunk): * enc/ebcdic.h: new dummy encoding EBCDIC-US — "U.NAKAMURA" <usa@...>
Hi,
On 2015/12/14 22:34, U.NAKAMURA wrote:
Hi,
[ruby-core:71989] [Ruby trunk - Feature #11781] Would it be possible to alias .prepend() towards .unshift() for class Array by default?
Issue #11781 has been updated by Nobuyoshi Nakada.
Their arities differ.
Let `String#prepend` take any number of arguments?
~~~diff
diff --git i/array.c w/array.c
index dd14837..b98142d 100644
--- i/array.c
+++ w/array.c
@@ -5832,6 +5832,7 @@ Init_Array(void)
rb_define_method(rb_cArray, "pop", rb_ary_pop_m, -1);
rb_define_method(rb_cArray, "shift", rb_ary_shift_m, -1);
rb_define_method(rb_cArray, "unshift", rb_ary_unshift_m, -1);
+ rb_define_method(rb_cArray, "prepend", rb_ary_unshift_m, -1);
rb_define_method(rb_cArray, "insert", rb_ary_insert, -1);
rb_define_method(rb_cArray, "each", rb_ary_each, 0);
rb_define_method(rb_cArray, "each_index", rb_ary_each_index, 0);
diff --git i/string.c w/string.c
index e6df91d..d0f6454 100644
--- i/string.c
+++ w/string.c
@@ -2691,21 +2691,28 @@ rb_str_concat(VALUE str1, VALUE str2)
/*
* call-seq:
- * str.prepend(other_str) -> str
+ * str.prepend(other_str, ...) -> str
*
* Prepend---Prepend the given string to <i>str</i>.
*
* a = "world"
* a.prepend("hello ") #=> "hello world"
* a #=> "hello world"
+ *
+ * a = "world"
+ * a.prepend("hello", " ") #=> "hello world"
+ * a #=> "hello world"
*/
static VALUE
-rb_str_prepend(VALUE str, VALUE str2)
+rb_str_prepend(int argc, VALUE *argv, VALUE str)
{
- StringValue(str2);
- StringValue(str);
- rb_str_update(str, 0L, 0L, str2);
+ int i;
+ for (i = argc; i > 0;) {
+ VALUE str2 = argv[--i];
+ StringValue(str2);
+ rb_str_update(str, 0L, 0L, str2);
+ }
return str;
}
@@ -9379,7 +9386,8 @@ Init_String(void)
rb_define_method(rb_cString, "reverse!", rb_str_reverse_bang, 0);
rb_define_method(rb_cString, "concat", rb_str_concat, 1);
rb_define_method(rb_cString, "<<", rb_str_concat, 1);
- rb_define_method(rb_cString, "prepend", rb_str_prepend, 1);
+ rb_define_method(rb_cString, "prepend", rb_str_prepend, -1);
+ rb_define_method(rb_cString, "unshift", rb_str_prepend, -1);
rb_define_method(rb_cString, "crypt", rb_str_crypt, 1);
rb_define_method(rb_cString, "intern", rb_str_intern, 0); /* in symbol.c */
rb_define_method(rb_cString, "to_sym", rb_str_intern, 0); /* in symbol.c */
diff --git i/test/ruby/test_string.rb w/test/ruby/test_string.rb
index eed7c69..853ef7c 100644
--- i/test/ruby/test_string.rb
+++ w/test/ruby/test_string.rb
@@ -2194,6 +2194,14 @@
a.prepend(b)
assert_equal(S("hello world"), a)
assert_equal(S("hello "), b)
+
+ a = S("world")
+ b = S("hel")
+ c = S("lo ")
+ a.prepend(b, c)
+ assert_equal(S("hello world"), a)
+ assert_equal(S("hel"), b)
+ assert_equal(S("lo "), c)
end
def u(str)
----------------------------------------
Feature #11781: Would it be possible to alias .prepend() towards .unshift() for class Array by default?
https://bugs.ruby-lang.org/issues/11781#change-55399
* Author: Robert A. Heiler
* Status: Open
* Priority: Normal
* Assignee:
----------------------------------------
Hello.
For Strings we can do:
abc = 'world!'
abc[0,0] = 'Hello '
abc # => "Hello world!"
For Arrays we can do:
abc = ['world!']
abc[0,0] = 'Hello '
abc # => ["Hello ", "world!"]
This is nice.
For Strings we can also use .prepend() to add to the beginning.
For Arrays, we have to use .unshift().
I have a hard time remembering .unshift though, .prepend() seems
to be easier for me to remember.
I'd like to use both .prepend for Strings and Arrays; right now
I have to use different names. I could alias prepend to unshift
for class Array, but then I'd have to carry these modifications
into my projects, which is not so good - I would prefer to just
stick to what MRI is doing.
Could we have the alias .prepend() for class Array, meaning
.unshift() too? That way I could use .prepend() for both Arrays
and Strings.
Thanks for reading!
--
https://bugs.ruby-lang.org/