Skip to content

Commit 2114d7a

Browse files
committed
Removed redundant specializations and improved guards in PermNode and CombNode
1 parent 45b1135 commit 2114d7a

File tree

1 file changed

+1
-21
lines changed

1 file changed

+1
-21
lines changed

graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/MathModuleBuiltins.java

Lines changed: 1 addition & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -571,16 +571,6 @@ PInt comb(PInt n, PInt k) {
571571
}
572572

573573
@Specialization
574-
int comb(@SuppressWarnings("unused") double n, @SuppressWarnings("unused") Object k) {
575-
throw raise(TypeError, ErrorMessages.OBJ_CANNOT_BE_INTERPRETED_AS_INTEGER, "float");
576-
}
577-
578-
@Specialization
579-
int comb(@SuppressWarnings("unused") Object n, @SuppressWarnings("unused") double k) {
580-
throw raise(TypeError, ErrorMessages.OBJ_CANNOT_BE_INTERPRETED_AS_INTEGER, "float");
581-
}
582-
583-
@Specialization(guards = "!isNumber(n) || !isNumber(k)")
584574
Object comb(VirtualFrame frame, Object n, Object k,
585575
@Cached("createBinaryProfile()") ConditionProfile hasFrame,
586576
@CachedLibrary(limit = "2") PythonObjectLibrary lib,
@@ -650,23 +640,13 @@ PInt perm(PInt n, PInt k) {
650640
return factory().createInt(calculatePerm(n.getValue(), k.getValue()));
651641
}
652642

653-
@Specialization
654-
int perm(@SuppressWarnings("unused") double n, @SuppressWarnings("unused") Object k) {
655-
throw raise(TypeError, ErrorMessages.OBJ_CANNOT_BE_INTERPRETED_AS_INTEGER, "float");
656-
}
657-
658-
@Specialization
659-
int perm(@SuppressWarnings("unused") Object n, @SuppressWarnings("unused") double k) {
660-
throw raise(TypeError, ErrorMessages.OBJ_CANNOT_BE_INTERPRETED_AS_INTEGER, "float");
661-
}
662-
663643
@Specialization
664644
Object perm(VirtualFrame frame, Object n, @SuppressWarnings("unused") PNone k,
665645
@Cached FactorialNode factorialNode) {
666646
return factorialNode.execute(frame, n);
667647
}
668648

669-
@Specialization(guards = "!isNumber(n) || !isNumber(k)")
649+
@Specialization(guards = "!isPNone(k)")
670650
Object perm(VirtualFrame frame, Object n, Object k,
671651
@Cached("createBinaryProfile()") ConditionProfile hasFrame,
672652
@CachedLibrary(limit = "2") PythonObjectLibrary lib,

0 commit comments

Comments
 (0)