52
52
import com .oracle .graal .python .builtins .modules .BuiltinFunctions .IterNode ;
53
53
import com .oracle .graal .python .builtins .objects .PNone ;
54
54
import com .oracle .graal .python .builtins .objects .function .PKeyword ;
55
- import com .oracle .graal .python .builtins .objects .iterator .IteratorNodes .ToArrayNode ;
56
55
import com .oracle .graal .python .builtins .objects .itertools .PAccumulate ;
57
56
import com .oracle .graal .python .builtins .objects .itertools .PChain ;
58
57
import com .oracle .graal .python .builtins .objects .itertools .PCombinations ;
77
76
import com .oracle .graal .python .lib .PyNumberAsSizeNode ;
78
77
import com .oracle .graal .python .lib .PyObjectGetIter ;
79
78
import com .oracle .graal .python .lib .PyObjectLookupAttr ;
80
- import com .oracle .graal .python .lib .PyObjectSizeNode ;
81
79
import com .oracle .graal .python .lib .PyObjectTypeCheck ;
82
80
import com .oracle .graal .python .nodes .ErrorMessages ;
81
+ import com .oracle .graal .python .builtins .objects .iterator .IteratorNodes .ToArrayNode ;
82
+ import com .oracle .graal .python .lib .PyObjectSizeNode ;
83
83
import com .oracle .graal .python .nodes .builtins .ListNodes .FastConstructListNode ;
84
84
import com .oracle .graal .python .nodes .call .special .CallVarargsMethodNode ;
85
85
import com .oracle .graal .python .nodes .function .PythonBuiltinBaseNode ;
@@ -574,18 +574,18 @@ protected ArgumentClinicProvider getArgumentClinic() {
574
574
575
575
@ Specialization (guards = {"isTypeNode.execute(cls)" , "isNone(r)" })
576
576
Object constructNoR (VirtualFrame frame , Object cls , Object iterable , @ SuppressWarnings ("unused" ) PNone r ,
577
- @ Cached PyObjectSizeNode sizeNode ,
577
+ @ Cached ToArrayNode toArrayNode ,
578
578
@ Cached ConditionProfile nrProfile ,
579
579
@ Cached LoopConditionProfile indicesLoopProfile ,
580
580
@ Cached LoopConditionProfile cyclesLoopProfile ,
581
581
@ SuppressWarnings ("unused" ) @ Cached IsTypeNode isTypeNode ) {
582
- int len = sizeNode .execute (frame , iterable );
583
- return construct (cls , iterable , len , len , nrProfile , indicesLoopProfile , cyclesLoopProfile );
582
+ Object [] pool = toArrayNode .execute (frame , iterable );
583
+ return construct (cls , pool , pool . length , nrProfile , indicesLoopProfile , cyclesLoopProfile );
584
584
}
585
585
586
586
@ Specialization (guards = {"isTypeNode.execute(cls)" , "!isNone(rArg)" })
587
587
Object construct (VirtualFrame frame , Object cls , Object iterable , Object rArg ,
588
- @ Cached PyObjectSizeNode sizeNode ,
588
+ @ Cached ToArrayNode toArrayNode ,
589
589
@ Cached CastToJavaIntExactNode castToInt ,
590
590
@ Cached BranchProfile wrongRprofile ,
591
591
@ Cached BranchProfile negRprofile ,
@@ -604,15 +604,15 @@ Object construct(VirtualFrame frame, Object cls, Object iterable, Object rArg,
604
604
negRprofile .enter ();
605
605
throw raise (ValueError , MUST_BE_NON_NEGATIVE , "r" );
606
606
}
607
- // XXX could be generator
608
- int len = sizeNode .execute (frame , iterable );
609
- return construct (cls , iterable , r , len , nrProfile , indicesLoopProfile , cyclesLoopProfile );
607
+ Object [] pool = toArrayNode .execute (frame , iterable );
608
+ return construct (cls , pool , r , nrProfile , indicesLoopProfile , cyclesLoopProfile );
610
609
}
611
610
612
- public PPermutations construct (Object cls , Object iterable , int r , int n , ConditionProfile nrProfile , LoopConditionProfile indicesLoopProfile , LoopConditionProfile cyclesLoopProfile ) {
611
+ public PPermutations construct (Object cls , Object [] pool , int r , ConditionProfile nrProfile , LoopConditionProfile indicesLoopProfile , LoopConditionProfile cyclesLoopProfile ) {
613
612
PPermutations self = factory ().createPermutations (cls );
614
- self .setPool (iterable );
613
+ self .setPool (pool );
615
614
self .setR (r );
615
+ int n = pool .length ;
616
616
self .setN (n );
617
617
int nMinusR = n - r ;
618
618
if (nrProfile .profile (nMinusR < 0 )) {
0 commit comments