Skip to content

Commit 2318fe6

Browse files
committed
Simplified PInt.asJavaDouble
1 parent 5f981e3 commit 2318fe6

File tree

1 file changed

+4
-14
lines changed
  • graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/ints

1 file changed

+4
-14
lines changed

graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/ints/PInt.java

Lines changed: 4 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -245,25 +245,15 @@ public boolean canBeJavaDouble() {
245245
@ExportMessage
246246
public double asJavaDouble(
247247
@CachedLibrary("this") PythonObjectLibrary lib,
248-
@Exclusive @Cached CastToJavaDoubleNode castToDouble,
249-
@Exclusive @Cached ConditionProfile hasIndexFunc,
250-
@Exclusive @Cached PRaiseNode raise) {
251-
if (hasIndexFunc.profile(lib.canBeIndex(this))) {
252-
return castToDouble.execute(lib.asIndex(this));
253-
}
254-
throw raise.raise(TypeError, ErrorMessages.MUST_BE_REAL_NUMBER, this);
248+
@Shared("castToDouble") @Cached CastToJavaDoubleNode castToDouble) {
249+
return castToDouble.execute(lib.asIndex(this));
255250
}
256251

257252
@ExportMessage
258253
public double asJavaDoubleWithState(ThreadState threadState,
259254
@CachedLibrary("this") PythonObjectLibrary lib,
260-
@Exclusive @Cached CastToJavaDoubleNode castToDouble,
261-
@Exclusive @Cached ConditionProfile hasIndexFunc,
262-
@Exclusive @Cached PRaiseNode raise) {
263-
if (hasIndexFunc.profile(lib.canBeIndex(this))) {
264-
return castToDouble.execute(lib.asIndexWithState(this, threadState));
265-
}
266-
throw raise.raise(TypeError, ErrorMessages.MUST_BE_REAL_NUMBER, this);
255+
@Shared("castToDouble") @Cached CastToJavaDoubleNode castToDouble) {
256+
return castToDouble.execute(lib.asIndexWithState(this, threadState));
267257
}
268258

269259
@SuppressWarnings("static-method")

0 commit comments

Comments
 (0)