summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--insns.def14
-rw-r--r--vm_insnhelper.c11
2 files changed, 13 insertions, 12 deletions
diff --git a/insns.def b/insns.def
index 91ae4563f0..d9a49356a6 100644
--- a/insns.def
+++ b/insns.def
@@ -730,12 +730,7 @@ opt_str_freeze
()
(VALUE val)
{
- if (BASIC_OP_UNREDEFINED_P(BOP_FREEZE, STRING_REDEFINED_OP_FLAG)) {
- val = str;
- }
- else {
- val = rb_funcall(rb_str_resurrect(str), idFreeze, 0);
- }
+ val = vm_opt_str_freeze(str, BOP_FREEZE, idFreeze);
}
DEFINE_INSN
@@ -744,12 +739,7 @@ opt_str_uminus
()
(VALUE val)
{
- if (BASIC_OP_UNREDEFINED_P(BOP_UMINUS, STRING_REDEFINED_OP_FLAG)) {
- val = str;
- }
- else {
- val = rb_funcall(rb_str_resurrect(str), idUMinus, 0);
- }
+ val = vm_opt_str_freeze(str, BOP_UMINUS, idUMinus);
}
DEFINE_INSN
diff --git a/vm_insnhelper.c b/vm_insnhelper.c
index 1f22cc64be..3fac8eb1fa 100644
--- a/vm_insnhelper.c
+++ b/vm_insnhelper.c
@@ -3213,6 +3213,17 @@ vm_find_or_create_class_by_id(ID id,
}
}
+static VALUE
+vm_opt_str_freeze(VALUE str, int bop, ID id)
+{
+ if (BASIC_OP_UNREDEFINED_P(bop, STRING_REDEFINED_OP_FLAG)) {
+ return str;
+ }
+ else {
+ return rb_funcall(rb_str_resurrect(str), id, 0);
+ }
+}
+
/* this macro is mandatory to use OPTIMIZED_CMP. What a design! */
#define id_cmp idCmp