Skip to content

feat: remove recursion from FilterItems #523

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Oct 27, 2023
Merged
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
18 changes: 8 additions & 10 deletions DynamoDbEncryption/dafny/DynamoDbEncryption/src/FilterExpr.dfy
Original file line number Diff line number Diff line change
Expand Up @@ -1429,17 +1429,15 @@ module DynamoDBFilterExpr {
ensures b.ValidState()
modifies b.Modifies()
{
if |ItemList| == 0 {
return Success([]);
}
var newAttrs :- b.GeneratePlainBeacons(ItemList[0]);
var doesMatch :- EvalExpr(parsed, ItemList[0] + newAttrs, names, values);
var rest :- FilterItems(b, parsed, ItemList[1..], names, values);
if doesMatch {
return Success(ItemList[..1] + rest);
} else {
return Success(rest);
var acc : DDB.ItemList := [];
for i := 0 to |ItemList| {
var newAttrs :- b.GeneratePlainBeacons(ItemList[i]);
var doesMatch :- EvalExpr(parsed, ItemList[i] + newAttrs, names, values);
if doesMatch {
acc := acc + [ItemList[i]];
}
}
return Success(acc);
}

// return the results for which the expression is true
Expand Down