Skip to content

Commit

Permalink
Fix return value of some find() functions
Browse files Browse the repository at this point in the history
  • Loading branch information
GrieferAtWork committed May 20, 2024
1 parent 718260f commit 84e873f
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 0 deletions.
4 changes: 4 additions & 0 deletions src/deemon/objects/list.c
Original file line number Diff line number Diff line change
Expand Up @@ -2756,6 +2756,8 @@ list_find(List *self, size_t argc, DeeObject *const *argv, DeeObject *kw) {
: list_find_impl(self, item, start, end);
if unlikely(result == (size_t)Dee_COMPARE_ERR)
goto err;
if unlikely(result == (size_t)-1)
return_reference_(DeeInt_MinusOne);
return DeeInt_NewSize(result);
err:
return NULL;
Expand All @@ -2774,6 +2776,8 @@ list_rfind(List *self, size_t argc, DeeObject *const *argv, DeeObject *kw) {
: list_rfind_impl(self, item, start, end);
if unlikely(result == (size_t)Dee_COMPARE_ERR)
goto err;
if unlikely(result == (size_t)-1)
return_reference_(DeeInt_MinusOne);
return DeeInt_NewSize(result);
err:
return NULL;
Expand Down
4 changes: 4 additions & 0 deletions src/deemon/objects/seq/default-api-methods.c
Original file line number Diff line number Diff line change
Expand Up @@ -2595,6 +2595,8 @@ generic_seq_find(DeeObject *self, size_t argc, DeeObject *const *argv, DeeObject
: new_DeeSeqFind(self, item, start, end);
if unlikely(result == (size_t)Dee_COMPARE_ERR)
goto err;
if unlikely(result == (size_t)-1)
return_reference_(DeeInt_MinusOne);
return DeeInt_NewSize(result);
err:
return NULL;
Expand All @@ -2613,6 +2615,8 @@ generic_seq_rfind(DeeObject *self, size_t argc, DeeObject *const *argv, DeeObjec
: new_DeeSeqRFind(self, item, start, end);
if unlikely(result == (size_t)Dee_COMPARE_ERR)
goto err;
if unlikely(result == (size_t)-1)
return_reference_(DeeInt_MinusOne);
return DeeInt_NewSize(result);
err:
return NULL;
Expand Down
4 changes: 4 additions & 0 deletions src/deemon/objects/seq/svec.c
Original file line number Diff line number Diff line change
Expand Up @@ -1244,6 +1244,8 @@ svec_find(SharedVector *self, size_t argc, DeeObject *const *argv, DeeObject *kw
: svec_find_impl(self, item, start, end);
if unlikely(result == (size_t)Dee_COMPARE_ERR)
goto err;
if unlikely(result == (size_t)-1)
return_reference_(DeeInt_MinusOne);
return DeeInt_NewSize(result);
err:
return NULL;
Expand All @@ -1262,6 +1264,8 @@ svec_rfind(SharedVector *self, size_t argc, DeeObject *const *argv, DeeObject *k
: svec_rfind_impl(self, item, start, end);
if unlikely(result == (size_t)Dee_COMPARE_ERR)
goto err;
if unlikely(result == (size_t)-1)
return_reference_(DeeInt_MinusOne);
return DeeInt_NewSize(result);
err:
return NULL;
Expand Down
4 changes: 4 additions & 0 deletions src/deemon/objects/tuple.c
Original file line number Diff line number Diff line change
Expand Up @@ -1939,6 +1939,8 @@ tuple_find(Tuple *self, size_t argc, DeeObject *const *argv, DeeObject *kw) {
: tuple_find_impl(self, item, start, end);
if unlikely(result == (size_t)Dee_COMPARE_ERR)
goto err;
if unlikely(result == (size_t)-1)
return_reference_(DeeInt_MinusOne);
return DeeInt_NewSize(result);
err:
return NULL;
Expand All @@ -1957,6 +1959,8 @@ tuple_rfind(Tuple *self, size_t argc, DeeObject *const *argv, DeeObject *kw) {
: tuple_rfind_impl(self, item, start, end);
if unlikely(result == (size_t)Dee_COMPARE_ERR)
goto err;
if unlikely(result == (size_t)-1)
return_reference_(DeeInt_MinusOne);
return DeeInt_NewSize(result);
err:
return NULL;
Expand Down
4 changes: 4 additions & 0 deletions src/dex/collections/fixedlist.c
Original file line number Diff line number Diff line change
Expand Up @@ -1407,6 +1407,8 @@ fl_find(FixedList *self, size_t argc, DeeObject *const *argv, DeeObject *kw) {
: fl_find_impl(self, item, start, end);
if unlikely(result == (size_t)Dee_COMPARE_ERR)
goto err;
if unlikely(result == (size_t)-1)
return_reference_(DeeInt_MinusOne);
return DeeInt_NewSize(result);
err:
return NULL;
Expand All @@ -1425,6 +1427,8 @@ fl_rfind(FixedList *self, size_t argc, DeeObject *const *argv, DeeObject *kw) {
: fl_rfind_impl(self, item, start, end);
if unlikely(result == (size_t)Dee_COMPARE_ERR)
goto err;
if unlikely(result == (size_t)-1)
return_reference_(DeeInt_MinusOne);
return DeeInt_NewSize(result);
err:
return NULL;
Expand Down

0 comments on commit 84e873f

Please sign in to comment.