Skip to content

Commit

Permalink
Check for empty lists more gracefully
Browse files Browse the repository at this point in the history
  • Loading branch information
jeaye committed Jan 16, 2024
1 parent e0b531a commit 04f64f7
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
5 changes: 5 additions & 0 deletions include/cpp/jank/runtime/detail/native_persistent_list.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -178,6 +178,11 @@ namespace jank::runtime::detail
return data ? data->length : 0;
}

native_bool empty() const
{
return data ? data->length == 0 : true;
}

option<T> first() const
{
if(data)
Expand Down
2 changes: 1 addition & 1 deletion src/cpp/jank/runtime/context.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -512,7 +512,7 @@ namespace jank::runtime
}
else
{
if(typed_o->data.data->length == 0)
if(typed_o->data.empty())
{
return typed_o;
}
Expand Down

0 comments on commit 04f64f7

Please sign in to comment.