Forum: Ruby ruby-dev summary 28274-28333

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
747db5c0f651123bed0a250dac908ada?d=identicon&s=25 Kazuo Saito (Guest)
on 2006-02-16 16:58
(Received via mailing list)
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
This topic is locked and can not be replied to.