This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
sv.c:sv_utf8_encode: simplify code
authorFather Chrysostomos <sprout@cpan.org>
Mon, 23 Jan 2012 06:58:58 +0000 (22:58 -0800)
committerFather Chrysostomos <sprout@cpan.org>
Mon, 23 Jan 2012 18:19:36 +0000 (10:19 -0800)
sv_force_normal already croaks for read-only variables

sv.c

diff --git a/sv.c b/sv.c
index 3094274..c1ece77 100644 (file)
--- a/sv.c
+++ b/sv.c
@@ -3521,11 +3521,8 @@ Perl_sv_utf8_encode(pTHX_ register SV *const sv)
 {
     PERL_ARGS_ASSERT_SV_UTF8_ENCODE;
 
-    if (SvIsCOW(sv)) {
-        sv_force_normal_flags(sv, 0);
-    }
     if (SvREADONLY(sv)) {
-       Perl_croak_no_modify(aTHX);
+       sv_force_normal_flags(sv, 0);
     }
     (void) sv_utf8_upgrade(sv);
     SvUTF8_off(sv);