[macruby-changes] [4099] MacRuby/trunk
source_changes at macosforge.org
source_changes at macosforge.org
Thu May 13 22:04:16 PDT 2010
Revision: 4099
http://trac.macosforge.org/projects/ruby/changeset/4099
Author: lsansonetti at apple.com
Date: 2010-05-13 22:04:11 -0700 (Thu, 13 May 2010)
Log Message:
-----------
faster #<<, #[] and #[]=
Modified Paths:
--------------
MacRuby/trunk/dispatcher.cpp
MacRuby/trunk/encoding.h
MacRuby/trunk/string.c
Modified: MacRuby/trunk/dispatcher.cpp
===================================================================
--- MacRuby/trunk/dispatcher.cpp 2010-05-14 03:41:14 UTC (rev 4098)
+++ MacRuby/trunk/dispatcher.cpp 2010-05-14 05:04:11 UTC (rev 4099)
@@ -1347,22 +1347,13 @@
unsigned char overriden)
{
if (overriden == 0) {
- switch (TYPE(obj)) {
- case T_ARRAY:
- if (*(VALUE *)obj == rb_cRubyArray) {
- return rary_push_m(obj, 0, other);
- }
- break;
-
-#if 0 // TODO
- case T_STRING:
- if (*(VALUE *)obj == rb_cCFString) {
- rb_str_concat(obj, other);
- return obj;
- }
- break;
-#endif
+ VALUE klass = CLASS_OF(obj);
+ if (klass == rb_cRubyArray) {
+ return rary_push_m(obj, 0, other);
}
+ else if (klass == rb_cRubyString) {
+ return rstr_concat(obj, 0, other);
+ }
}
return __rb_vm_dispatch(GET_VM(), cache, 0, obj, NULL, selLTLT, NULL, 0, 1,
&other);
@@ -1373,19 +1364,14 @@
rb_vm_fast_aref(VALUE obj, VALUE other, struct mcache *cache,
unsigned char overriden)
{
- if (overriden == 0)
- switch (TYPE(obj)) {
- case T_ARRAY:
- if (*(VALUE *)obj == rb_cRubyArray) {
- return rary_aref(obj, 0, 1, &other);
- }
- break;
-
- case T_HASH:
- if (*(VALUE *)obj == rb_cRubyHash) {
- return rhash_aref(obj, 0, other);
- }
- break;
+ if (overriden == 0) {
+ VALUE klass = CLASS_OF(obj);
+ if (klass == rb_cRubyArray) {
+ return rary_aref(obj, 0, 1, &other);
+ }
+ else if (klass == rb_cRubyHash) {
+ return rhash_aref(obj, 0, other);
+ }
}
return __rb_vm_dispatch(GET_VM(), cache, 0, obj, NULL, selAREF, NULL, 0, 1,
&other);
@@ -1397,22 +1383,16 @@
unsigned char overriden)
{
if (overriden == 0) {
- switch (TYPE(obj)) {
- case T_ARRAY:
- if (*(VALUE *)obj == rb_cRubyArray) {
- if (TYPE(other1) == T_FIXNUM) {
- rary_store(obj, FIX2LONG(other1), other2);
- return other2;
- }
- }
- break;
-
- case T_HASH:
- if (*(VALUE *)obj == rb_cRubyHash) {
- return rhash_aset(obj, 0, other1, other2);
- }
- break;
+ VALUE klass = CLASS_OF(obj);
+ if (klass == rb_cRubyArray) {
+ if (TYPE(other1) == T_FIXNUM) {
+ rary_store(obj, FIX2LONG(other1), other2);
+ return other2;
+ }
}
+ else if (klass == rb_cRubyHash) {
+ return rhash_aset(obj, 0, other1, other2);
+ }
}
VALUE args[2] = { other1, other2 };
return __rb_vm_dispatch(GET_VM(), cache, 0, obj, NULL, selASET, NULL, 0, 2,
Modified: MacRuby/trunk/encoding.h
===================================================================
--- MacRuby/trunk/encoding.h 2010-05-14 03:41:14 UTC (rev 4098)
+++ MacRuby/trunk/encoding.h 2010-05-14 05:04:11 UTC (rev 4099)
@@ -303,6 +303,7 @@
VALUE rstr_capitalize(VALUE str, SEL sel);
VALUE rstr_upcase(VALUE str, SEL sel);
VALUE rstr_downcase(VALUE str, SEL sel);
+VALUE rstr_concat(VALUE self, SEL sel, VALUE other);
// The following functions should always been prefered over anything else,
// especially if this "else" is RSTRING_PTR and RSTRING_LEN.
Modified: MacRuby/trunk/string.c
===================================================================
--- MacRuby/trunk/string.c 2010-05-14 03:41:14 UTC (rev 4098)
+++ MacRuby/trunk/string.c 2010-05-14 05:04:11 UTC (rev 4099)
@@ -2573,7 +2573,7 @@
* a.concat(33) #=> "hello world!"
*/
-static VALUE
+VALUE
rstr_concat(VALUE self, SEL sel, VALUE other)
{
rstr_modify(self);
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.macosforge.org/pipermail/macruby-changes/attachments/20100513/7fd6df1f/attachment.html>
More information about the macruby-changes
mailing list