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

ruby-changes:74320

From: Peter <ko1@a...>
Date: Thu, 3 Nov 2022 00:05:07 +0900 (JST)
Subject: [ruby-changes:74320] 4a8cd9e8bc (master): Use shared flags of the type

https://git.ruby-lang.org/ruby.git/commit/?id=4a8cd9e8bc

From 4a8cd9e8bca2be1c14310cc13366ec9177a1f74d Mon Sep 17 00:00:00 2001
From: Peter Zhu <peter@p...>
Date: Wed, 2 Nov 2022 11:03:21 -0400
Subject: Use shared flags of the type

The ELTS_SHARED flag is generic, so we should prefer to use the flags
specific of the type (STR_SHARED for strings and RARRAY_SHARED_FLAG
for arrays).
---
 ext/objspace/objspace_dump.c | 3 ++-
 internal/string.h            | 2 +-
 2 files changed, 3 insertions(+), 2 deletions(-)

diff --git a/ext/objspace/objspace_dump.c b/ext/objspace/objspace_dump.c
index 2917d49331..7c7cae3488 100644
--- a/ext/objspace/objspace_dump.c
+++ b/ext/objspace/objspace_dump.c
@@ -14,6 +14,7 @@ https://github.com/ruby/ruby/blob/trunk/ext/objspace/objspace_dump.c#L14
 
 #include "gc.h"
 #include "internal.h"
+#include "internal/array.h"
 #include "internal/hash.h"
 #include "internal/string.h"
 #include "internal/sanitizers.h"
@@ -456,7 +457,7 @@ dump_object(VALUE obj, struct dump_config *dc) https://github.com/ruby/ruby/blob/trunk/ext/objspace/objspace_dump.c#L457
       case T_ARRAY:
         dump_append(dc, ", \"length\":");
         dump_append_ld(dc, RARRAY_LEN(obj));
-        if (RARRAY_LEN(obj) > 0 && FL_TEST(obj, ELTS_SHARED))
+        if (RARRAY_LEN(obj) > 0 && FL_TEST(obj, RARRAY_SHARED_FLAG))
             dump_append(dc, ", \"shared\":true");
         if (FL_TEST(obj, RARRAY_EMBED_FLAG))
             dump_append(dc, ", \"embedded\":true");
diff --git a/internal/string.h b/internal/string.h
index 43b716f9b2..12edbff2b1 100644
--- a/internal/string.h
+++ b/internal/string.h
@@ -106,7 +106,7 @@ STR_EMBED_P(VALUE str) https://github.com/ruby/ruby/blob/trunk/internal/string.h#L106
 static inline bool
 STR_SHARED_P(VALUE str)
 {
-    return FL_ALL_RAW(str, STR_NOEMBED | ELTS_SHARED);
+    return FL_ALL_RAW(str, STR_NOEMBED | STR_SHARED);
 }
 
 static inline bool
-- 
cgit v1.2.3


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

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