@@ -245,25 +245,15 @@ public boolean canBeJavaDouble() {
245
245
@ ExportMessage
246
246
public double asJavaDouble (
247
247
@ 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 ));
255
250
}
256
251
257
252
@ ExportMessage
258
253
public double asJavaDoubleWithState (ThreadState threadState ,
259
254
@ 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 ));
267
257
}
268
258
269
259
@ SuppressWarnings ("static-method" )
0 commit comments