Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions src/filters.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -487,7 +487,7 @@ InternalValue SequenceAccessor::Filter(const InternalValue& baseVal, RenderConte
switch (m_mode)
{
case FirstItemMode:
if (listSize)
if (listSize && *listSize > 0)
result = ProtectedValue( list.GetValueByIndex(0) );
else
{
Expand All @@ -497,7 +497,7 @@ InternalValue SequenceAccessor::Filter(const InternalValue& baseVal, RenderConte
}
break;
case LastItemMode:
if (listSize)
if (listSize && *listSize > 0)
result = ProtectedValue(list.GetValueByIndex(listSize.value() - 1));
else
{
Expand All @@ -508,7 +508,7 @@ InternalValue SequenceAccessor::Filter(const InternalValue& baseVal, RenderConte
}
break;
case LengthMode:
if (listSize)
if (listSize && *listSize > 0)
result = static_cast<int64_t>(listSize.value());
else
result = static_cast<int64_t>(std::distance(list.begin(), list.end()));
Expand All @@ -517,7 +517,7 @@ InternalValue SequenceAccessor::Filter(const InternalValue& baseVal, RenderConte
{
std::random_device rd;
std::mt19937 gen(rd());
if (listSize)
if (listSize && *listSize > 0)
{
std::uniform_int_distribution<> dis(0, static_cast<int>(listSize.value()) - 1);
result = ProtectedValue(list.GetValueByIndex(dis(gen)));
Expand Down