[macruby-changes] [3730] MacRuby/branches/icu/marshal.c
source_changes at macosforge.org
source_changes at macosforge.org
Tue Mar 9 20:39:55 PST 2010
Revision: 3730
http://trac.macosforge.org/projects/ruby/changeset/3730
Author: lsansonetti at apple.com
Date: 2010-03-09 20:39:52 -0800 (Tue, 09 Mar 2010)
Log Message:
-----------
optimized Marshal.dump in case an IO object is provided
Modified Paths:
--------------
MacRuby/branches/icu/marshal.c
Modified: MacRuby/branches/icu/marshal.c
===================================================================
--- MacRuby/branches/icu/marshal.c 2010-03-10 03:09:42 UTC (rev 3729)
+++ MacRuby/branches/icu/marshal.c 2010-03-10 04:39:52 UTC (rev 3730)
@@ -220,11 +220,15 @@
{
VALUE buf = arg->str;
rb_bstr_concat(buf, (const uint8_t *)s, n);
+#if 0 // unused
if (arg->dest && RSTRING_LEN(buf) >= BUFSIZ) {
- if (arg->taint) OBJ_TAINT(buf);
+ if (arg->taint) {
+ OBJ_TAINT(buf);
+ }
rb_io_write(arg->dest, 0, buf);
rb_str_resize(buf, 0);
}
+#endif
}
static void
@@ -896,10 +900,12 @@
dump(struct dump_call_arg *arg)
{
w_object(arg->obj, arg->arg, arg->limit);
+#if 0 // unused
if (arg->arg->dest) {
rb_io_write(arg->arg->dest, 0, arg->arg->str);
rb_bstr_resize(arg->arg->str, 0);
}
+#endif
return 0;
}
@@ -977,16 +983,20 @@
}
}
arg->dest = 0;
+ bool got_io = false;
if (!NIL_P(port)) {
if (!rb_obj_respond_to(port, s_write, Qtrue)) {
type_error:
rb_raise(rb_eTypeError, "instance of IO needed");
}
GC_WB(&arg->str, rb_bstr_new());
+#if 0 // unused
GC_WB(&arg->dest, port);
+#endif
if (rb_obj_respond_to(port, s_binmode, Qtrue)) {
rb_funcall2(port, s_binmode, 0, 0);
}
+ got_io = true;
}
else {
port = rb_bstr_new();
@@ -1008,6 +1018,12 @@
rb_ensure(dump, (VALUE)c_arg, dump_ensure, (VALUE)arg);
+ // If we got an IO object as the port, make sure to write the bytestring
+ // to it before leaving!
+ if (got_io) {
+ rb_io_write(port, 0, arg->str);
+ }
+
return port;
}
@@ -1743,6 +1759,7 @@
v = rb_check_string_type(port);
if (!NIL_P(v)) {
arg->taint = OBJ_TAINTED(port); /* original taintedness */
+ v = rb_str_bstr(v);
port = v;
}
else if (rb_obj_respond_to(port, s_getbyte, Qtrue)
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.macosforge.org/pipermail/macruby-changes/attachments/20100309/93685912/attachment.html>
More information about the macruby-changes
mailing list