summaryrefslogtreecommitdiff
path: root/string.c
diff options
context:
space:
mode:
authornormal <normal@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2018-06-04 23:26:03 +0000
committernormal <normal@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2018-06-04 23:26:03 +0000
commit256411b47fd486b40eb3cfe3760dca06f62c830f (patch)
tree43240911dfe108eb5a1f30d8c037dcf79d732397 /string.c
parentb3cb6dbafc9f2c19d111395670d4d72f472ee43a (diff)
String#uminus dedupes unconditionally
[Feature #14478] [ruby-core:85669] Thanks-to: Sam Saffron <sam.saffron@gmail.com> git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@63566 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'string.c')
-rw-r--r--string.c14
1 files changed, 5 insertions, 9 deletions
diff --git a/string.c b/string.c
index 36126eb805..088df21b40 100644
--- a/string.c
+++ b/string.c
@@ -2607,20 +2607,16 @@ str_uplus(VALUE str)
* call-seq:
* -str -> str (frozen)
*
- * If the string is frozen, then return the string itself.
+ * Return a frozen, possibly pre-existing
+ * copy of the string.
*
- * If the string is not frozen, return a frozen, possibly pre-existing
- * copy of it.
+ * String will be deduplicated as long as it is not tainted,
+ * or has any instance vars set on it.
*/
static VALUE
str_uminus(VALUE str)
{
- if (OBJ_FROZEN(str)) {
- return str;
- }
- else {
- return rb_fstring(str);
- }
+ return rb_fstring(str);
}
RUBY_ALIAS_FUNCTION(rb_str_dup_frozen(VALUE str), rb_str_new_frozen, (str))