Skip to content

Commit

Permalink
Add Program.builtins_len() method (#1194)
Browse files Browse the repository at this point in the history
* Add Program.builtins_len() method

* Update CHANGELOG.md
  • Loading branch information
pefontana committed May 31, 2023
1 parent 09ea750 commit 5db2e65
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 0 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
## Cairo-VM Changelog

#### Upcoming Changes
* Add `Program::builtins_len method` [#1194](https://github.com/lambdaclass/cairo-rs/pull/1194)

* fix: Handle the deserialization of serde_json::Number with scientific notation (e.g.: Number(1e27)) in felt_from_number function [#1188](https://github.com/lambdaclass/cairo-rs/pull/1188)

* bugfix: Use cairo constants in `ASSERT_250_BIT` hint [#1187](https://github.com/lambdaclass/cairo-rs/pull/1187)
Expand Down
6 changes: 6 additions & 0 deletions src/types/program.rs
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,10 @@ impl Program {
self.shared_program_data.data.len()
}

pub fn builtins_len(&self) -> usize {
self.builtins.len()
}

pub fn get_identifier(&self, id: &str) -> Option<&Identifier> {
self.shared_program_data.identifiers.get(id)
}
Expand Down Expand Up @@ -351,6 +355,8 @@ mod tests {
program.iter_builtins().cloned().collect::<Vec<_>>(),
builtins
);

assert_eq!(program.builtins_len(), 2);
}

#[test]
Expand Down

1 comment on commit 5db2e65

@github-actions
Copy link

Choose a reason for hiding this comment

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

⚠️ Performance Alert ⚠️

Possible performance regression was detected for benchmark.
Benchmark result of this commit is worse than the previous benchmark result exceeding threshold 1.30.

Benchmark suite Current: 5db2e65 Previous: 09ea750 Ratio
add_u64_with_felt/3 2 ns/iter (± 0) 1 ns/iter (± 0) 2
add_u64_with_felt/4 2 ns/iter (± 0) 1 ns/iter (± 0) 2

This comment was automatically generated by workflow using github-action-benchmark.

CC: @unbalancedparentheses

Please sign in to comment.