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: use a slice to pass function arguments #42

Merged
merged 1 commit into from
Jun 23, 2024
Merged

Conversation

aesterline
Copy link
Member

This should allow use a temporary vec/slice when calling fuctions, which will allow us to release memory for function calls that will not be needed in the result. We are hoping this will lower our overall memory footprint.

This should allow use a temporary vec/slice when calling fuctions, which
will allow us to release memory for function calls that will not be
needed in the result. We are hoping this will lower our overall memory
footprint.
@aesterline aesterline enabled auto-merge (squash) June 23, 2024 15:20
max_args!(context, args, 1);

let arg = &args[0];
let arg = args.first().copied().unwrap_or_else(Value::undefined);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wonder if it's worth, for ergonomics, defining something like:

trait ArgsIndex<'a> {
  fn get(i: usize) -> &'a Value<'a>;
}

impl ArgsIndex for &[&'a Value<'a>] {
  ...
}

@aesterline aesterline merged commit 4dbb9b7 into main Jun 23, 2024
5 checks passed
@aesterline aesterline deleted the slice-arguments branch June 23, 2024 18:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants