Skip to content
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

refactor: don't use a temporary bump-allocated Array in eval_step #46

Merged
merged 1 commit into from
Jun 25, 2024
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
10 changes: 5 additions & 5 deletions src/evaluator.rs
Original file line number Diff line number Diff line change
Expand Up @@ -755,7 +755,7 @@ impl<'a> Evaluator<'a> {
return Ok(result);
}

let result = Value::array_with_capacity(self.arena, input.len(), ArrayFlags::SEQUENCE);
let mut result: Vec<&'a Value<'a>> = Vec::new();

// Evaluate the step on each member of the input
for (item_index, item) in input.members().enumerate() {
Expand All @@ -781,16 +781,16 @@ impl<'a> Evaluator<'a> {
Ok(
if last_step
&& result.len() == 1
&& result.get_member(0).is_array()
&& !result.get_member(0).has_flags(ArrayFlags::SEQUENCE)
&& result[0].is_array()
&& !result[0].has_flags(ArrayFlags::SEQUENCE)
{
result.get_member(0)
result.remove(0)
} else {
// Flatten the result sequence
let result_sequence =
Value::array_with_capacity(self.arena, result.len(), ArrayFlags::SEQUENCE);

for result_item in result.members() {
for result_item in result {
if !result_item.is_array() || result_item.has_flags(ArrayFlags::CONS) {
result_sequence.push(result_item);
} else {
Expand Down