diff options
author | Koichi Sasada <ko1@atdot.net> | 2020-10-14 02:10:54 +0900 |
---|---|---|
committer | Koichi Sasada <ko1@atdot.net> | 2020-10-14 14:02:06 +0900 |
commit | 102c2ba65f1fa2a6cdbaaa7d2b466aabfc50e5d7 (patch) | |
tree | 321280f87f8a4e46abb66d8293778e906e3840e5 | |
parent | 11c2f0f36ccc50899a8dd69a260e85451f68b5ba (diff) | |
download | ruby-102c2ba65f1fa2a6cdbaaa7d2b466aabfc50e5d7.tar.gz |
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]
-rw-r--r-- | encoding.c | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/encoding.c b/encoding.c index 20bc257d4a..7f0ea73ad1 100644 --- a/encoding.c +++ b/encoding.c @@ -122,7 +122,10 @@ rb_data_is_encoding(VALUE obj) 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 |