[perl-Glib] Avoid an unnecessary hash conversion



commit 853d24c008ecde529ba708a9ce3892e3859bcb17
Author: Kevin Ryde <user42 zip com au>
Date:   Sun Dec 16 17:28:09 2012 +1100

    Avoid an unnecessary hash conversion
    
    In Glib::Object::Subclass' import(), pass @_ directly to
    Glib::Type->register_object(), no need to hash through %arg. Saves a couple of
    nanoseconds and avoids non-deterministism due to the change to hash
    randomization in perl 5.17.6.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=690459

 lib/Glib/Object/Subclass.pm |    8 +++++---
 1 files changed, 5 insertions(+), 3 deletions(-)
---
diff --git a/lib/Glib/Object/Subclass.pm b/lib/Glib/Object/Subclass.pm
index 1652d8e..8324ada 100644
--- a/lib/Glib/Object/Subclass.pm
+++ b/lib/Glib/Object/Subclass.pm
@@ -223,16 +223,18 @@ do that.  Especially watch out for other classes in your ISA tree.
 *new = \&Glib::Object::new;
 
 sub import {
+   shift;  # $self
+
    # we seem to be imported by classes using classes which use us.
    # ignore anything that doesn't look like a registration attempt.
-   return unless @_ > 1;
+   return unless @_;
 
-   my ($self, $superclass, %arg) = @_;
+   my $superclass = shift;
    my $class = caller;
 
    Glib::Type->register_object(
       $superclass, $class,
-      %arg,
+      @_,
    );
 
    # ensure that we have a perlish new().  the old version of this



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