diff options
author | matz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2006-09-02 14:42:08 +0000 |
---|---|---|
committer | matz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2006-09-02 14:42:08 +0000 |
commit | 2156870525be05f0bd769af141c3f6cff9fff8c4 (patch) | |
tree | 3e6db7f9ecee480edff058e18bc7211a53296f64 /ruby.h | |
parent | 8581164ea67a13fad5e7d56aa4aa75a87f9eafb3 (diff) | |
download | ruby-2156870525be05f0bd769af141c3f6cff9fff8c4.tar.gz |
* ruby.h (struct RArray): embed small arrays.
(RARRAY_LEN): defined for accessing array members.
(RARRAY_PTR): ditto.
* array.c: use RARRAY_LEN and RARRAY_PTR.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@10833 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'ruby.h')
-rw-r--r-- | ruby.h | 28 |
1 files changed, 23 insertions, 5 deletions
@@ -390,15 +390,33 @@ struct RString { RSTRING(str)->as.ary : \ RSTRING(str)->as.heap.ptr) +#define RARRAY_EMBED_LEN_MAX 3 struct RArray { struct RBasic basic; - long len; union { - long capa; - VALUE shared; - } aux; - VALUE *ptr; + struct { + long len; + union { + long capa; + VALUE shared; + } aux; + VALUE *ptr; + } heap; + VALUE ary[RARRAY_EMBED_LEN_MAX]; + } as; }; +#define RARRAY_NOEMBED FL_USER3 +#define RARRAY_EMBED_LEN_MASK (FL_USER4|FL_USER5) +#define RARRAY_EMBED_LEN_SHIFT (FL_USHIFT+4) +#define RARRAY_LEN(a) \ + (!(RBASIC(a)->flags & RARRAY_NOEMBED) ? \ + (long)((RBASIC(a)->flags >> RARRAY_EMBED_LEN_SHIFT) & \ + (RARRAY_EMBED_LEN_MASK >> RARRAY_EMBED_LEN_SHIFT)) : \ + RARRAY(a)->as.heap.len) +#define RARRAY_PTR(a) \ + (!(RBASIC(a)->flags & RARRAY_NOEMBED) ? \ + RARRAY(a)->as.ary : \ + RARRAY(a)->as.heap.ptr) struct RRegexp { struct RBasic basic; |