[前][次][番号順一覧][スレッド一覧]

ruby-changes:63340

From: Koichi <ko1@a...>
Date: Wed, 14 Oct 2020 14:02:36 +0900 (JST)
Subject: [ruby-changes:63340] 102c2ba65f (master): freeze Encoding objects

https://git.ruby-lang.org/ruby.git/commit/?id=102c2ba65f

From 102c2ba65f1fa2a6cdbaaa7d2b466aabfc50e5d7 Mon Sep 17 00:00:00 2001
From: Koichi Sasada <ko1@a...>
Date: Wed, 14 Oct 2020 02:10:54 +0900
Subject: freeze Encoding objects

Encoding objects can be accessed in multi-ractors and there is no
state to mutate. So we can mark it as frozen and shareable.
[Bug #17188]

diff --git a/encoding.c b/encoding.c
index 20bc257..7f0ea73 100644
--- a/encoding.c
+++ b/encoding.c
@@ -122,7 +122,10 @@ rb_data_is_encoding(VALUE obj) https://github.com/ruby/ruby/blob/trunk/encoding.c#L122
 static VALUE
 enc_new(rb_encoding *encoding)
 {
-    return TypedData_Wrap_Struct(rb_cEncoding, &encoding_data_type, (void *)encoding);
+    VALUE enc = TypedData_Wrap_Struct(rb_cEncoding, &encoding_data_type, (void *)encoding);
+    rb_obj_freeze(enc);
+    FL_SET_RAW(enc, RUBY_FL_SHAREABLE);
+    return enc;
 }
 
 static void
-- 
cgit v0.10.2


--
ML: ruby-changes@q...
Info: http://www.atdot.net/~ko1/quickml/

[前][次][番号順一覧][スレッド一覧]