@@ -215,17 +215,17 @@ bool SortedDictType::is_nargs_good(char const* caller, Py_ssize_t nargs, int at_
215215}
216216
217217/* *
218- * Find the lower bound of the given good key and report whether it was found.
219- * (To determine whether a good key is present, check the second element of the
218+ * Try to find the given good key.
219+ *
220+ * To determine whether a good key is present, check the second element of the
220221 * result; there is no meaningful performance impact of doing this instead of
221- * calling `find` directly because it internally does the same thing done
222- * here.)
222+ * calling `find` directly because it internally does the same thing done here.
223223 *
224224 * @param key Good key.
225225 *
226226 * @return The lower bound of the given key and whether it was found.
227227 */
228- std::pair<FwdIterType, bool > SortedDictType::lower_bound_and_found (PyObject* key)
228+ std::pair<FwdIterType, bool > SortedDictType::try_find (PyObject* key)
229229{
230230 auto it = this ->map ->lower_bound (key);
231231 return { it, it != this ->map ->end () && !this ->map ->key_comp ()(key, it->first ) };
@@ -415,7 +415,7 @@ int SortedDictType::contains(PyObject* key, PyObject* value)
415415 {
416416 return -1 ;
417417 }
418- auto [it, found] = this ->lower_bound_and_found (key);
418+ auto [it, found] = this ->try_find (key);
419419 if (!found)
420420 {
421421 return 0 ;
@@ -450,7 +450,7 @@ PyObject* SortedDictType::getitem(PyObject* key)
450450 {
451451 return nullptr ;
452452 }
453- auto [it, found] = this ->lower_bound_and_found (key);
453+ auto [it, found] = this ->try_find (key);
454454 if (!found)
455455 {
456456 PyErr_SetObject (PyExc_KeyError, key);
@@ -477,7 +477,7 @@ int SortedDictType::setitem(PyObject* key, PyObject* value)
477477
478478 // Insertion will be faster if the approximate location is known. Hence,
479479 // look for the nearest match.
480- auto [it, found] = this ->lower_bound_and_found (key);
480+ auto [it, found] = this ->try_find (key);
481481
482482 if (value == nullptr )
483483 {
@@ -574,7 +574,7 @@ PyObject* SortedDictType::get(PyObject* const* args, Py_ssize_t nargs)
574574 {
575575 return nullptr ;
576576 }
577- auto [it, found] = this ->lower_bound_and_found (key);
577+ auto [it, found] = this ->try_find (key);
578578 if (found)
579579 {
580580 return Py_NewRef (it->second .value ); // 🆕
@@ -604,7 +604,7 @@ PyObject* SortedDictType::setdefault(PyObject* const* args, Py_ssize_t nargs)
604604 {
605605 return nullptr ;
606606 }
607- auto [it, found] = this ->lower_bound_and_found (key);
607+ auto [it, found] = this ->try_find (key);
608608 if (found)
609609 {
610610 return Py_NewRef (it->second .value ); // 🆕
0 commit comments