summaryrefslogtreecommitdiffhomepage
path: root/include
diff options
context:
space:
mode:
authorYukihiro "Matz" Matsumoto <[email protected]>2019-08-12 17:09:21 +0900
committerGitHub <[email protected]>2019-08-12 17:09:21 +0900
commitad0b54608888330c4bc25c9b4520a9cb3446f24d (patch)
treed9964a403ad7f1a49f0e258f4fc007a39a9fb956 /include
parent285ce9d8aa9ecfd7b749ae02784a2ba68290293a (diff)
parent450684ab33f3b13bde520f831f857fe1e7dc5fd6 (diff)
downloadmruby-ad0b54608888330c4bc25c9b4520a9cb3446f24d.tar.gz
mruby-ad0b54608888330c4bc25c9b4520a9cb3446f24d.zip
Merge pull request #4626 from shuujii/mrb_str_modify_keep_ascii-can-embed-one-more-byte
`mrb_str_modify_keep_ascii` can embed one more byte
Diffstat (limited to 'include')
-rw-r--r--include/mruby/string.h2
1 files changed, 2 insertions, 0 deletions
diff --git a/include/mruby/string.h b/include/mruby/string.h
index 7266c9084..aacbdbfc0 100644
--- a/include/mruby/string.h
+++ b/include/mruby/string.h
@@ -52,6 +52,8 @@ struct RString {
} while (0)
#define RSTR_EMBED_LEN(s)\
(mrb_int)(((s)->flags & MRB_STR_EMBED_LEN_MASK) >> MRB_STR_EMBED_LEN_SHIFT)
+#define RSTR_EMBEDDABLE_P(len) ((len) <= RSTRING_EMBED_LEN_MAX)
+
#define RSTR_PTR(s) ((RSTR_EMBED_P(s)) ? (s)->as.ary : (s)->as.heap.ptr)
#define RSTR_LEN(s) ((RSTR_EMBED_P(s)) ? RSTR_EMBED_LEN(s) : (s)->as.heap.len)
#define RSTR_CAPA(s) (RSTR_EMBED_P(s) ? RSTRING_EMBED_LEN_MAX : (s)->as.heap.aux.capa)