[svn:parrot] r46145 - trunk/src/string

petdance at svn.parrot.org petdance at svn.parrot.org
Thu Apr 29 16:04:46 UTC 2010


Author: petdance
Date: Thu Apr 29 16:04:46 2010
New Revision: 46145
URL: https://trac.parrot.org/parrot/changeset/46145

Log:
collapse redundant calls to Parrot_str_new_init

Modified:
   trunk/src/string/api.c

Modified: trunk/src/string/api.c
==============================================================================
--- trunk/src/string/api.c	Thu Apr 29 16:04:44 2010	(r46144)
+++ trunk/src/string/api.c	Thu Apr 29 16:04:46 2010	(r46145)
@@ -497,14 +497,10 @@
 {
     ASSERT_ARGS(Parrot_str_new)
     /* Force an 8-bit encoding at some point? */
-    if (len)
-        return Parrot_str_new_init(interp, buffer, len,
-            PARROT_DEFAULT_ENCODING, PARROT_DEFAULT_CHARSET, 0);
-    else {
-        const UINTVAL buff_length = buffer ? strlen(buffer) : 0;
-        return Parrot_str_new_init(interp, buffer, buff_length,
-            PARROT_DEFAULT_ENCODING, PARROT_DEFAULT_CHARSET, 0);
-    }
+    const UINTVAL buff_length = (len > 0) ? len : buffer ? strlen(buffer) : 0;
+
+    return Parrot_str_new_init(interp, buffer, buff_length,
+        PARROT_DEFAULT_ENCODING, PARROT_DEFAULT_CHARSET, 0);
 }
 
 


More information about the parrot-commits mailing list