[perl-Cairo] Calculate a string length more efficiently



commit 6fb1ed5a6f09e5f53897a61c4097cbbbf0f38116
Author: Torsten SchÃnfeld <kaffeetisch gmx de>
Date:   Sat Jun 9 00:54:12 2012 +0200

    Calculate a string length more efficiently

 CairoSurface.xs |    5 ++++-
 1 files changed, 4 insertions(+), 1 deletions(-)
---
diff --git a/CairoSurface.xs b/CairoSurface.xs
index e84ea27..3a834e2 100644
--- a/CairoSurface.xs
+++ b/CairoSurface.xs
@@ -279,7 +279,10 @@ read_func_marshaller (void *closure,
 		SvREFCNT_dec (sv);
 	} else {
 		SV *retval = POPs;
-		memcpy (data, SvPV_nolen (retval), sv_len (retval));
+		STRLEN len = 0;
+		const char *sv_data = SvPV (retval, len);
+		/* should we assert that len == length? */
+		memcpy (data, sv_data, len);
 	}
 
 	PUTBACK;



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]