[pygobject] Remove redundant info.get_name calls



commit 6b36fbe904d19f515578f447daa7657d3a9a859c
Author: Simon Feltman <sfeltman src gnome org>
Date:   Sat Jul 13 18:11:18 2013 -0700

    Remove redundant info.get_name calls
    
    Remove a number of redundant calls to GIBaseInfo.get_name. Info
    names are already cached on function objects so re-use them when
    possible. This gives a small load time improvement by removing over
    2000 calls when importing Gtk.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=704037

 gi/module.py |    1 -
 gi/types.py  |    8 +++-----
 2 files changed, 3 insertions(+), 6 deletions(-)
---
diff --git a/gi/module.py b/gi/module.py
index 4368217..9b9dfbc 100644
--- a/gi/module.py
+++ b/gi/module.py
@@ -208,7 +208,6 @@ class IntrospectionModule(object):
                     self.__dict__[name] = type_
                     return type_
 
-            name = info.get_name()
             dict_ = {
                 '__info__': info,
                 '__module__': 'gi.repository.' + self._namespace,
diff --git a/gi/types.py b/gi/types.py
index b9c0e37..54e38a1 100644
--- a/gi/types.py
+++ b/gi/types.py
@@ -95,13 +95,11 @@ class MetaClassHelper(object):
     def _setup_constructors(cls):
         for method_info in cls.__info__.get_methods():
             if method_info.is_constructor():
-                name = method_info.get_name()
-                constructor = classmethod(Constructor(method_info))
-                setattr(cls, name, constructor)
+                constructor = Constructor(method_info)
+                setattr(cls, constructor.__name__, classmethod(constructor))
 
     def _setup_methods(cls):
         for method_info in cls.__info__.get_methods():
-            name = method_info.get_name()
             function = Function(method_info)
             if method_info.is_method():
                 method = function
@@ -109,7 +107,7 @@ class MetaClassHelper(object):
                 continue
             else:
                 method = staticmethod(function)
-            setattr(cls, name, method)
+            setattr(cls, function.__name__, method)
 
     def _setup_fields(cls):
         for field_info in cls.__info__.get_fields():


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