This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
Remove a duplicated conditional test by putting everything for the
authorNicholas Clark <nick@ccl4.org>
Fri, 17 Mar 2006 20:39:47 +0000 (20:39 +0000)
committerNicholas Clark <nick@ccl4.org>
Fri, 17 Mar 2006 20:39:47 +0000 (20:39 +0000)
not readonly case inside one block.

p4raw-id: //depot/perl@27537

sv.c

diff --git a/sv.c b/sv.c
index 5c4722d..d981d88 100644 (file)
--- a/sv.c
+++ b/sv.c
@@ -5297,13 +5297,14 @@ Perl_sv_len_utf8(pTHX_ register SV *sv)
        }
        else {
            ulen = Perl_utf8_length(aTHX_ s, s + len);
-           if (!mg && !SvREADONLY(sv)) {
-               sv_magic(sv, 0, PERL_MAGIC_utf8, 0, 0);
-               mg = mg_find(sv, PERL_MAGIC_utf8);
-               assert(mg);
-           }
-           if (mg)
+           if (!SvREADONLY(sv)) {
+               if (!mg) {
+                   sv_magic(sv, 0, PERL_MAGIC_utf8, 0, 0);
+                   mg = mg_find(sv, PERL_MAGIC_utf8);
+                   assert(mg);
+               }
                mg->mg_len = ulen;
+           }
        }
        return ulen;
     }