summaryrefslogtreecommitdiff
path: root/string.c
diff options
context:
space:
mode:
authorko1 <ko1@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2014-07-06 17:20:30 +0000
committerko1 <ko1@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2014-07-06 17:20:30 +0000
commit7ad35210a360db5a6b90eb3a9955636df930b133 (patch)
tree3b1f7a892b99d9a6c091ea9b0a051137079b4bbb /string.c
parent2006bfe2f42d0458e061a1798680cb78b80fdbe8 (diff)
* string.c (fstr_update_callback): do not use rb_gc_resurrect()
any more. Make new frozen string and replace with garbage frozen string. * common.mk: use gc.h from string.c. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@46727 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'string.c')
-rw-r--r--string.c31
1 files changed, 19 insertions, 12 deletions
diff --git a/string.c b/string.c
index e9d342bc69..1a46f467ad 100644
--- a/string.c
+++ b/string.c
@@ -16,6 +16,7 @@
#include "ruby/encoding.h"
#include "internal.h"
#include "probes.h"
+#include "gc.h"
#include <assert.h>
#define BEG(no) (regs->beg[(no)])
@@ -191,22 +192,28 @@ fstr_update_callback(st_data_t *key, st_data_t *value, st_data_t arg, int existi
if (existing) {
/* because of lazy sweep, str may be unmarked already and swept
* at next time */
- rb_gc_resurrect(*fstr = *key);
- return ST_STOP;
- }
- if (STR_SHARED_P(str)) {
- /* str should not be shared */
- str = rb_enc_str_new(RSTRING_PTR(str), RSTRING_LEN(str), STR_ENC_GET(str));
- OBJ_FREEZE(str);
+ if (rb_objspace_garbage_object_p(str)) {
+ goto create_new_fstr;
+ }
+
+ *fstr = str;
+ return ST_STOP;
}
else {
- str = rb_str_new_frozen(str);
- }
- RBASIC(str)->flags |= RSTRING_FSTR;
+ if (STR_SHARED_P(str)) { /* str should not be shared */
+ create_new_fstr:
+ str = rb_enc_str_new(RSTRING_PTR(str), RSTRING_LEN(str), STR_ENC_GET(str));
+ OBJ_FREEZE(str);
+ }
+ else {
+ str = rb_str_new_frozen(str);
+ }
+ RBASIC(str)->flags |= RSTRING_FSTR;
- *key = *value = *fstr = str;
- return ST_CONTINUE;
+ *key = *value = *fstr = str;
+ return ST_CONTINUE;
+ }
}
VALUE