[glibmm/gmmproc-refactor] Do not look for conversion if it is not needed.
- From: Krzesimir Nowak <krnowak src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [glibmm/gmmproc-refactor] Do not look for conversion if it is not needed.
- Date: Mon, 9 Jul 2012 20:37:06 +0000 (UTC)
commit dacd0b5511cd1cc438f3ee37d67bfd9ead8cdfe2
Author: Krzesimir Nowak <qdlacz gmail com>
Date: Mon Jul 9 22:19:52 2012 +0200
Do not look for conversion if it is not needed.
tools/pm/Common/TypeInfo/Local.pm | 43 ++++++++++++++++++++++++++----------
1 files changed, 31 insertions(+), 12 deletions(-)
---
diff --git a/tools/pm/Common/TypeInfo/Local.pm b/tools/pm/Common/TypeInfo/Local.pm
index 10a3ca5..5808a58 100644
--- a/tools/pm/Common/TypeInfo/Local.pm
+++ b/tools/pm/Common/TypeInfo/Local.pm
@@ -90,6 +90,24 @@ sub _get_named_conversion ($$$$$)
return undef;
}
+sub _get_identity_conversion
+{
+ my ($self, $from, $to, $transfer, $subst) = @_;
+
+ if ($transfer == Common::TypeInfo::Common::TRANSFER_NONE)
+ {
+ my $from_details = Common::TypeDetails::disassemble_type ($from);
+ my $to_details = Common::TypeDetails::disassemble_type ($to);
+
+ if ($from_details->equal ($to_details, Common::TypeDetails::Base::RECURSIVE))
+ {
+ return $subst;
+ }
+ }
+
+ return undef;
+}
+
sub new ($$)
{
my ($type, $global) = @_;
@@ -239,24 +257,25 @@ sub pop_named_conversion ($$)
sub get_conversion ($$$$$)
{
my ($self, $from, $to, $transfer, $subst) = @_;
- my $conversion = $self->_get_named_conversion ($from, $to, $transfer, $subst);
-
- unless (defined ($conversion))
+ my @conversion_subs =
+ (
+ sub { return $self->_get_identity_conversion ($from, $to, $transfer, $subst); },
+ sub { return $self->_get_named_conversion ($from, $to, $transfer, $subst); },
+ sub { my $conversions = $self->_get_conversions (); return Common::TypeInfo::Common::get_specific_conversion ($conversions, $from, $to, $transfer, $subst); },
+ sub { my $global = $self->_get_global (); return $global->get_conversion ($from, $to, $transfer, $subst); }
+ );
+
+ foreach my $conversion_sub (@conversion_subs)
{
- my $conversions = $self->_get_conversions;
-
- $conversion = Common::TypeInfo::Common::get_specific_conversion $conversions, $from, $to, $transfer, $subst;
+ my $conversion = &{$conversion_sub} ();
- unless (defined $conversion)
+ if (defined ($conversion))
{
- my $global = $self->_get_global;
-
- # this will throw an exception when nothing is found.
- $conversion = $global->get_conversion ($from, $to, $transfer, $subst);
+ return $conversion;
}
}
- return $conversion;
+ return undef;
}
sub c_to_cxx ($$)
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]