diff options
author | Nobuyoshi Nakada <[email protected]> | 2024-10-07 18:45:07 +0900 |
---|---|---|
committer | Nobuyoshi Nakada <[email protected]> | 2024-10-07 18:45:07 +0900 |
commit | dbb1abacf0538db61496cd25d9616dfa18327cd9 (patch) | |
tree | a988b85435d71585d035b4a996911c16214173f1 | |
parent | 66b69d4ea553485306b683d7f965181dffca5205 (diff) |
Make rbconfig/sizeof keys as literals
These keys are made from string literals, and used only as keys of
hashes.
Notes
Notes:
Merged: https://github.com/ruby/ruby/pull/11814
-rw-r--r-- | template/limits.c.tmpl | 2 | ||||
-rw-r--r-- | template/sizes.c.tmpl | 4 |
2 files changed, 3 insertions, 3 deletions
diff --git a/template/limits.c.tmpl b/template/limits.c.tmpl index d1e5b44592..a46cf5ed63 100644 --- a/template/limits.c.tmpl +++ b/template/limits.c.tmpl @@ -82,7 +82,7 @@ Init_limits(void) #define MAX2NUM(name) ULONG2NUM(name ## _MAX) #define MIN2NUM(name) LONG2NUM(name ## _MIN) #endif -#define DEFINE(k, v) rb_hash_aset(h, rb_str_new_cstr(#k), v) +#define DEFINE(k, v) rb_hash_aset(h, rb_str_new_lit(#k), v) % limits.each do |type| #ifdef <%= type %>_MAX diff --git a/template/sizes.c.tmpl b/template/sizes.c.tmpl index 909902fd17..d44ef378fe 100644 --- a/template/sizes.c.tmpl +++ b/template/sizes.c.tmpl @@ -47,8 +47,8 @@ Init_sizeof(void) VALUE mRbConfig = rb_define_module("RbConfig"); rb_define_const(mRbConfig, "SIZEOF", s); -#define DEFINE(type, size) rb_hash_aset(s, rb_str_new_cstr(#type), INT2FIX(SIZEOF_##size)) -#define DEFINE_SIZE(type) rb_hash_aset(s, rb_str_new_cstr(#type), INT2FIX(sizeof(type))) +#define DEFINE(type, size) rb_hash_aset(s, rb_str_new_lit(#type), INT2FIX(SIZEOF_##size)) +#define DEFINE_SIZE(type) rb_hash_aset(s, rb_str_new_lit(#type), INT2FIX(sizeof(type))) % types.each do |type| % if sizes[type] |