summaryrefslogtreecommitdiff
path: root/compile.c
diff options
context:
space:
mode:
authornormal <normal@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2017-03-10 20:09:06 +0000
committernormal <normal@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2017-03-10 20:09:06 +0000
commit568f8adfc884d1897eca56c8b6c0ec0018cf3816 (patch)
tree1a9fea1c18286ad0a8689df70a75825a0961dcc8 /compile.c
parentc51de81d8edb78de83cb0645830153f448349d8d (diff)
compile.c: apply opt_str_freeze to String#-@ (uminus)
The same optimization used for "literal string".freeze can easily apply to uminus without introducing any compatibility problems. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@57828 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'compile.c')
-rw-r--r--compile.c3
1 files changed, 2 insertions, 1 deletions
diff --git a/compile.c b/compile.c
index f1ba0946b3..be38c63dea 100644
--- a/compile.c
+++ b/compile.c
@@ -5188,7 +5188,8 @@ iseq_compile_each(rb_iseq_t *iseq, LINK_ANCHOR *const ret, NODE *node, int poppe
* "literal".freeze -> opt_str_freeze("literal")
*/
if (node->nd_recv && nd_type(node->nd_recv) == NODE_STR &&
- node->nd_mid == idFreeze && node->nd_args == NULL &&
+ (node->nd_mid == idFreeze || node->nd_mid == idUMinus) &&
+ node->nd_args == NULL &&
ISEQ_COMPILE_DATA(iseq)->current_block == NULL &&
ISEQ_COMPILE_DATA(iseq)->option->specialized_instruction) {
VALUE str = rb_fstring(node->nd_recv->nd_lit);