From: Nicholas Clark <nick@ccl4.org>
Date: Sun, 13 Jan 2008 20:58:56 +0000 (+0000)
Subject: Re-order so that the !SvOK() case is last (which should be rare)
X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=656266fc5211f7fea3afa655730ed10f45b205ea;p=p5sagit%2Fp5-mst-13.2.git

Re-order so that the !SvOK() case is last (which should be rare)
Remove the FIXME comment as I had already fixed it.

p4raw-id: //depot/perl@32971
---

diff --git a/pp.c b/pp.c
index 6110b4c..c667e22 100644
--- a/pp.c
+++ b/pp.c
@@ -3018,11 +3018,7 @@ PP(pp_length)
     dVAR; dSP; dTARGET;
     SV * const sv = TOPs;
 
-    if (!SvOK(sv) && !SvGMAGICAL(sv)) {
-	/* FIXME - this doesn't allow GMAGIC to return undef for consistency.
-	 */
-	SETs(&PL_sv_undef);
-    } else if (SvGAMAGIC(sv)) {
+    if (SvGAMAGIC(sv)) {
 	/* For an overloaded or magic scalar, we can't know in advance if
 	   it's going to be UTF-8 or not. Also, we can't call sv_len_utf8 as
 	   it likes to cache the length. Maybe that should be a documented
@@ -3040,12 +3036,14 @@ PP(pp_length)
 	}
 	else
 	    SETi(len);
-    } else {
+    } else if (SvOK(sv)) {
 	/* Neither magic nor overloaded.  */
 	if (DO_UTF8(sv))
 	    SETi(sv_len_utf8(sv));
 	else
 	    SETi(sv_len(sv));
+    } else {
+	SETs(&PL_sv_undef);
     }
     RETURN;
 }