[perl-Glib] Avoid having to search for our magic twice



commit 948c00447ace130306d3445de4a3c2903364af09
Author: Florian Ragwitz <rafl debian org>
Date:   Wed Nov 24 23:00:47 2010 +0100

    Avoid having to search for our magic twice
    
    In gperl_get_object_check, keep around and use the result of gperl_find_mg
    instead of calling it a second time (and having to traverse the whole magic list
    again) via gperl_get_object.

 GObject.xs |    5 +++--
 1 files changed, 3 insertions(+), 2 deletions(-)
---
diff --git a/GObject.xs b/GObject.xs
index 29e4bc4..afccc4b 100644
--- a/GObject.xs
+++ b/GObject.xs
@@ -980,6 +980,7 @@ GObject *
 gperl_get_object_check (SV * sv,
 			GType gtype)
 {
+	MAGIC *mg;
 	const char * package;
 	package = gperl_object_package_from_type (gtype);
 	if (!package)
@@ -989,12 +990,12 @@ gperl_get_object_check (SV * sv,
 		croak ("%s is not of type %s",
 		       gperl_format_variable_for_output (sv),
 		       package);
-	if (!_gperl_find_mg (SvRV (sv)))
+	if (!(mg = _gperl_find_mg (SvRV (sv))))
 		croak ("%s is not a proper Glib::Object "
 		       "(it doesn't contain the right magic)",
 		       gperl_format_variable_for_output (sv));
 
-	return gperl_get_object (sv);
+	return (GObject *) mg->mg_ptr;
 }
 
 



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