Skip to content

Commit a316f34

Browse files
committed
Remove some redundant checks.
1 parent e67d414 commit a316f34

File tree

1 file changed

+5
-10
lines changed

1 file changed

+5
-10
lines changed

Objects/dictobject.c

+5-10
Original file line numberDiff line numberDiff line change
@@ -1324,9 +1324,8 @@ PyDict_GetItem(PyObject *op, PyObject *key)
13241324
/* Ignore any exception raised by the lookup */
13251325
_PyErr_Restore(tstate, exc_type, exc_value, exc_tb);
13261326

1327-
if (ix < 0) {
1328-
return NULL;
1329-
}
1327+
1328+
assert(ix >= 0 || value == NULL);
13301329
return value;
13311330
}
13321331

@@ -1385,9 +1384,7 @@ _PyDict_GetItem_KnownHash(PyObject *op, PyObject *key, Py_hash_t hash)
13851384
}
13861385

13871386
ix = _Py_dict_lookup(mp, key, hash, &value);
1388-
if (ix < 0) {
1389-
return NULL;
1390-
}
1387+
assert(ix >= 0 || value == NULL);
13911388
return value;
13921389
}
13931390

@@ -1417,8 +1414,7 @@ PyDict_GetItemWithError(PyObject *op, PyObject *key)
14171414
}
14181415

14191416
ix = _Py_dict_lookup(mp, key, hash, &value);
1420-
if (ix < 0)
1421-
return NULL;
1417+
assert(ix >= 0 || value == NULL);
14221418
return value;
14231419
}
14241420

@@ -1478,8 +1474,7 @@ _PyDict_LoadGlobal(PyDictObject *globals, PyDictObject *builtins, PyObject *key)
14781474

14791475
/* namespace 2: builtins */
14801476
ix = _Py_dict_lookup(builtins, key, hash, &value);
1481-
if (ix < 0)
1482-
return NULL;
1477+
assert(ix >= 0 || value == NULL);
14831478
return value;
14841479
}
14851480

0 commit comments

Comments
 (0)