@@ -183,26 +183,21 @@ protected void removeItem(VirtualFrame frame, PDict dict, Object key,
183
183
}
184
184
}
185
185
186
- @ SuppressWarnings ("unused" )
187
- @ Specialization (guards = "isNoValue(arg1)" , limit = "3" )
188
- public Object pop (VirtualFrame frame , PDict dict , Object arg0 , PNone arg1 ,
189
- @ Cached BranchProfile updatedStorage ,
190
- @ Cached ("createBinaryProfile()" ) ConditionProfile hasFrame ,
191
- @ CachedLibrary ("dict.getDictStorage()" ) HashingStorageLibrary lib ) {
192
- return popDefault (frame , dict , arg0 , PNone .NONE , updatedStorage , hasFrame , lib );
193
- }
194
-
195
186
@ Specialization (limit = "3" )
196
187
public Object popDefault (VirtualFrame frame , PDict dict , Object key , Object defaultValue ,
197
188
@ Cached BranchProfile updatedStorage ,
198
- @ Cached ("createBinaryProfile()" ) ConditionProfile hasFrame ,
189
+ @ Cached ConditionProfile hasKey ,
190
+ @ Cached ConditionProfile hasDefault ,
191
+ @ Cached ConditionProfile hasFrame ,
199
192
@ CachedLibrary ("dict.getDictStorage()" ) HashingStorageLibrary lib ) {
200
193
Object retVal = lib .getItemWithFrame (dict .getDictStorage (), key , hasFrame , frame );
201
- if (retVal != null ) {
194
+ if (hasKey . profile ( retVal != null ) ) {
202
195
removeItem (frame , dict , key , lib , hasFrame , updatedStorage );
203
196
return retVal ;
204
- } else {
197
+ } else if ( hasDefault . profile ( defaultValue != PNone . NO_VALUE )) {
205
198
return defaultValue ;
199
+ } else {
200
+ throw raise (PythonBuiltinClassType .KeyError , "%s" , key );
206
201
}
207
202
}
208
203
}
0 commit comments