summaryrefslogtreecommitdiff
path: root/include/ruby
diff options
context:
space:
mode:
authorPeter Zhu <peter@peterzhu.ca>2021-08-02 12:16:24 -0400
committerPeter Zhu <peter@peterzhu.ca>2021-10-25 13:26:23 -0400
commit46b66eb9e8e6de2d5750591e532310e8f8599d90 (patch)
treeda3ad8c60694fcf374fa09582b0b172f8805e0ff /include/ruby
parent09fa773e04f183e5eb685f07e174efa2cf77f9dc (diff)
[Feature #18239] Add struct for embedded strings
Notes
Notes: Merged: https://github.com/ruby/ruby/pull/4933
Diffstat (limited to 'include/ruby')
-rw-r--r--include/ruby/internal/core/rstring.h21
1 files changed, 11 insertions, 10 deletions
diff --git a/include/ruby/internal/core/rstring.h b/include/ruby/internal/core/rstring.h
index d16a57b1c4..f7d0539a0c 100644
--- a/include/ruby/internal/core/rstring.h
+++ b/include/ruby/internal/core/rstring.h
@@ -270,15 +270,16 @@ struct RString {
VALUE shared;
} aux;
} heap;
-
- /**
- * Embedded contents. When a string is short enough, it uses this area
- * to store the contents themselves. This was impractical in the 20th
- * century, but these days 64 bit machines can typically hold 48 bytes
- * here. Could be sufficiently large. In this case the length is
- * encoded into the flags.
- */
- char ary[RSTRING_EMBED_LEN_MAX + 1];
+ struct {
+ /**
+ * Embedded contents. When a string is short enough, it uses this area
+ * to store the contents themselves. This was impractical in the 20th
+ * century, but these days 64 bit machines can typically hold 48 bytes
+ * here. Could be sufficiently large. In this case the length is
+ * encoded into the flags.
+ */
+ char ary[RSTRING_EMBED_LEN_MAX + 1];
+ } embed;
} as;
};
@@ -440,7 +441,7 @@ rbimpl_rstring_getmem(VALUE str)
/* Expecting compilers to optimize this on-stack struct away. */
struct RString retval;
retval.as.heap.len = RSTRING_EMBED_LEN(str);
- retval.as.heap.ptr = RSTRING(str)->as.ary;
+ retval.as.heap.ptr = RSTRING(str)->as.embed.ary;
return retval;
}
}