summaryrefslogtreecommitdiffhomepage
path: root/include
diff options
context:
space:
mode:
authorYukihiro Matsumoto <[email protected]>2012-06-03 07:55:39 +0900
committerYukihiro Matsumoto <[email protected]>2012-06-03 07:55:39 +0900
commit12d75223d62ed90f334980c3a15e96618250fe90 (patch)
treecd5facb0373fd3a74d457ee2289682a67ed29e55 /include
parent5fcd520514095fa9bbb31d2e7eca192b1be7dfc2 (diff)
downloadmruby-12d75223d62ed90f334980c3a15e96618250fe90.tar.gz
mruby-12d75223d62ed90f334980c3a15e96618250fe90.zip
make shared string to reference-counted C structure to reduce GC pressure
Diffstat (limited to 'include')
-rw-r--r--include/mruby/string.h15
1 files changed, 7 insertions, 8 deletions
diff --git a/include/mruby/string.h b/include/mruby/string.h
index 39f119ae8..852c5ff02 100644
--- a/include/mruby/string.h
+++ b/include/mruby/string.h
@@ -25,12 +25,18 @@ extern "C" {
extern const char mrb_digitmap[];
+struct mrb_shared_string {
+ int refcnt;
+ char *buf;
+ int len;
+};
+
struct RString {
MRUBY_OBJECT_HEADER;
int len;
union {
int capa;
- struct RString *shared;
+ struct mrb_shared_string *shared;
} aux;
char *buf;
};
@@ -41,14 +47,7 @@ struct RString {
#define RSTRING_LEN(s) (RSTRING(s)->len)
#define RSTRING_CAPA(s) (RSTRING(s)->aux.capa)
#define RSTRING_END(s) (RSTRING(s)->buf + RSTRING(s)->len)
-
#define MRB_STR_SHARED 256
-#define MRB_STR_SHARED_P(s) (FL_ALL(s, MRB_STR_SHARED))
-#define MRB_STR_NOCAPA (MRB_STR_SHARED)
-#define MRB_STR_NOCAPA_P(s) (FL_ANY(s, MRB_STR_NOCAPA))
-#define MRB_STR_UNSET_NOCAPA(s) do {\
- FL_UNSET(s, MRB_STR_NOCAPA);\
-} while (0)
mrb_value mrb_str_literal(mrb_state*, mrb_value);
void mrb_str_concat(mrb_state*, mrb_value, mrb_value);