[pygobject] pyg_value_from_pyobject(): Simplify GVariant type check
- From: Martin Pitt <martinpitt src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [pygobject] pyg_value_from_pyobject(): Simplify GVariant type check
- Date: Wed, 14 Nov 2012 08:35:02 +0000 (UTC)
commit f3b77f4304be20b7422c262b973f3eeb540c4bf6
Author: Martin Pitt <martinpitt gnome org>
Date: Wed Nov 14 09:33:43 2012 +0100
pyg_value_from_pyobject(): Simplify GVariant type check
Use pyg_type_from_object_strict() instead of the much more expensive and local
pyg_get_gvariant_type().
gi/_gobject/pygtype.c | 23 +----------------------
1 files changed, 1 insertions(+), 22 deletions(-)
---
diff --git a/gi/_gobject/pygtype.c b/gi/_gobject/pygtype.c
index fe2c3b6..adc8c12 100644
--- a/gi/_gobject/pygtype.c
+++ b/gi/_gobject/pygtype.c
@@ -727,26 +727,6 @@ pyg_value_array_from_pyobject(GValue *value,
return 0;
}
-static
-PyObject *
-pyg_get_gvariant_type()
-{
- static PyObject *variant_type = NULL;
- PyObject *py_module;
-
- if (variant_type == NULL) {
- py_module = PyImport_ImportModule ("gi.repository.GLib");
- if (py_module == NULL)
- return NULL;
-
- variant_type = PyObject_GetAttrString (py_module, "Variant");
-
- Py_DECREF (py_module);
- }
-
- return variant_type;
-}
-
/**
* pyg_value_from_pyobject:
* @value: the GValue object to store the converted value in.
@@ -1013,10 +993,9 @@ pyg_value_from_pyobject(GValue *value, PyObject *obj)
break;
case G_TYPE_VARIANT:
{
- PyObject* variant_type = pyg_get_gvariant_type();
if (obj == Py_None)
g_value_set_variant(value, NULL);
- else if (variant_type != NULL && PyObject_IsInstance(obj, variant_type))
+ else if (pyg_type_from_object_strict(obj, FALSE) == G_TYPE_VARIANT)
g_value_set_variant(value, pyg_boxed_get(obj, GVariant));
else
return -1;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]