From: Kazuo Saito Date: 2006-02-17T00:57:55+09:00 Subject: ruby-dev summary 28274-28333 Hello all, This is a summary of ruby-dev mailing list. [ruby-dev:28290] [Oniguruma] Version 4.0.0 K.Kosako released the new version of Oniguruma. Matz imported the source into Ruby CVS repository. The release has fixes for bug in handling comments in regexp, invalid error when compiling recursive regexp patterns, and optimization for regexps beginning with ".*". [ruby-dev:28296] packing small Struct Tanaka Akira posted a patch for allocating small Struct objects with less memory consumption. It is useful for structs which has less than 3 elements in it, like cons cells. The patch packs the elements into the RStruct object itself like this patch for ruby.h: +#define RSTRUCT_EMBED_LEN_MAX 3 struct RStruct { struct RBasic basic; - long len; - VALUE *ptr; + union { + struct { + long len; + VALUE *ptr; + } heap; + VALUE ary[RSTRUCT_EMBED_LEN_MAX]; + } as; }; +#define RSTRUCT_EMBED_LEN_MASK (FL_USER1|FL_USER0) +#define RSTRUCT_EMBED_LEN_SHIFT FL_USHIFT +#define RSTRUCT_LEN(st) \ + ((RBASIC(st)->flags & RSTRUCT_EMBED_LEN_MASK) ? \ + (RBASIC(st)->flags >> RSTRUCT_EMBED_LEN_SHIFT) & 3 : \ + RSTRUCT(st)->as.heap.len) +#define RSTRUCT_PTR(st) \ + ((RBASIC(st)->flags & RSTRUCT_EMBED_LEN_MASK) ? \ + RSTRUCT(st)->as.ary : \ + RSTRUCT(st)->as.heap.ptr) Tanaka said that the patch makes us to change all codes using "RSTRUCT(obj)->ptr" or "RSTRUCT(obj)->len" to use the macros above. But it was not so difficult because the change is simple, and it will be replaced automatically by editor or tools. Also, compiler can detect all unchanged codes. Hidetoshi Nagai agreed to change Ruby/Tk codes to fit the macros. At the end of the post, He added that the idea may be applicable for RString and RArray. Matz accepted the patch and said that he have a similar idea for Values and other objects shorter than 11 bytes(12 bytes - NUL terminator). Tanaka-san showed us a profile for the length of String objects in Ruby interpreter at startup. According to reply from Matz, number of shorter objects seems to be increased when loading other libraries, rexml for example. ruby-dev summary index: http://i.loveruby.net/en/ruby-dev-summary.html