Created
September 13, 2011 15:38
-
-
Save mlschroe/1214140 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
diff --git a/src/how/NQPClassHOW.pm b/src/how/NQPClassHOW.pm | |
index 4e9b979..3fdbd25 100644 | |
--- a/src/how/NQPClassHOW.pm | |
+++ b/src/how/NQPClassHOW.pm | |
@@ -254,14 +254,18 @@ knowhow NQPClassHOW { | |
# Provided we have immediate parents... | |
my @result; | |
if +@immediate_parents { | |
- # Build merge list of lineraizations of all our parents, add | |
- # immediate parents and merge. | |
- my @merge_list; | |
- for @immediate_parents { | |
- @merge_list.push(compute_c3_mro($_)); | |
+ if +@immediate_parents == 1 { | |
+ @result := compute_c3_mro(@immediate_parents[0]); | |
+ } else { | |
+ # Build merge list of lineraizations of all our parents, add | |
+ # immediate parents and merge. | |
+ my @merge_list; | |
+ for @immediate_parents { | |
+ @merge_list.push(compute_c3_mro($_)); | |
+ } | |
+ @merge_list.push(@immediate_parents); | |
+ @result := c3_merge(@merge_list); | |
} | |
- @merge_list.push(@immediate_parents); | |
- @result := c3_merge(@merge_list); | |
} | |
# Put this class on the start of the list, and we're done. | |
@@ -347,12 +351,14 @@ knowhow NQPClassHOW { | |
# Walk MRO and add methods to cache, unless another method | |
# lower in the class hierarchy "shadowed" it. | |
my %cache; | |
+ my @mro_reversed; | |
for @!mro { | |
+ @mro_reversed.unshift($_); | |
+ } | |
+ for @mro_reversed { | |
my %methods := $_.HOW.method_table($_); | |
for %methods { | |
- unless %cache{$_.key} { | |
- %cache{$_.key} := $_.value; | |
- } | |
+ %cache{$_.key} := $_.value; | |
} | |
} | |
pir::publish_method_cache($obj, %cache); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment