@@ -262,17 +262,17 @@ bool SortedDictType::is_nargs_good(char const* caller, Py_ssize_t nargs, int at_
262262}
263263
264264/* *
265- * Find the lower bound of the given good key and report whether it was found.
266- * (To determine whether a good key is present, check the second element of the
265+ * Try to find the given good key.
266+ *
267+ * To determine whether a good key is present, check the second element of the
267268 * result; there is no meaningful performance impact of doing this instead of
268- * calling `find` directly because it internally does the same thing done
269- * here.)
269+ * calling `find` directly because it internally does the same thing done here.
270270 *
271271 * @param key Good key.
272272 *
273273 * @return The lower bound of the given key and whether it was found.
274274 */
275- std::pair<FwdIterType, bool > SortedDictType::lower_bound_and_found (PyObject* key)
275+ std::pair<FwdIterType, bool > SortedDictType::try_find (PyObject* key)
276276{
277277 auto it = this ->map ->lower_bound (key);
278278 return { it, it != this ->map ->end () && !this ->map ->key_comp ()(key, it->first ) };
@@ -462,7 +462,7 @@ int SortedDictType::contains(PyObject* key, PyObject* value)
462462 {
463463 return -1 ;
464464 }
465- auto [it, found] = this ->lower_bound_and_found (key);
465+ auto [it, found] = this ->try_find (key);
466466 if (!found)
467467 {
468468 return 0 ;
@@ -497,7 +497,7 @@ PyObject* SortedDictType::getitem(PyObject* key)
497497 {
498498 return nullptr ;
499499 }
500- auto [it, found] = this ->lower_bound_and_found (key);
500+ auto [it, found] = this ->try_find (key);
501501 if (!found)
502502 {
503503 PyErr_SetObject (PyExc_KeyError, key);
@@ -524,7 +524,7 @@ int SortedDictType::setitem(PyObject* key, PyObject* value)
524524
525525 // Insertion will be faster if the approximate location is known. Hence,
526526 // look for the nearest match.
527- auto [it, found] = this ->lower_bound_and_found (key);
527+ auto [it, found] = this ->try_find (key);
528528
529529 if (value == nullptr )
530530 {
@@ -621,7 +621,7 @@ PyObject* SortedDictType::get(PyObject* const* args, Py_ssize_t nargs)
621621 {
622622 return nullptr ;
623623 }
624- auto [it, found] = this ->lower_bound_and_found (key);
624+ auto [it, found] = this ->try_find (key);
625625 if (found)
626626 {
627627 return Py_NewRef (it->second .value ); // 🆕
@@ -651,7 +651,7 @@ PyObject* SortedDictType::setdefault(PyObject* const* args, Py_ssize_t nargs)
651651 {
652652 return nullptr ;
653653 }
654- auto [it, found] = this ->lower_bound_and_found (key);
654+ auto [it, found] = this ->try_find (key);
655655 if (found)
656656 {
657657 return Py_NewRef (it->second .value ); // 🆕
0 commit comments