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

Fix typos #36

Merged
merged 2 commits into from
Mar 27, 2024
Merged
Show file tree
Hide file tree
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
21 changes: 20 additions & 1 deletion .github/workflows/main.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
on:
push:
branches: [ "main" ]
branches:
- main
- actions-*
pull_request:
branches: [ "main" ]

Expand All @@ -24,6 +26,23 @@ jobs:
- name: Run cargo build
run: cargo build --verbose

bench:
name: Bench
runs-on: ubuntu-latest
steps:
- name: Checkout sources
uses: actions/checkout@v3

- name: Install nightly toolchain
uses: actions-rs/toolchain@v1
with:
profile: minimal
toolchain: nightly
override: true

- name: Run cargo bench
run: cargo +nightly bench --verbose

test:
name: Test
runs-on: ubuntu-latest
Expand Down
14 changes: 7 additions & 7 deletions benches/generator/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -79,12 +79,12 @@ pub fn gen_add_remove_patches<R: Rng>(
patches: usize,
operations: usize,
) -> Vec<Patch> {
let leafs = all_leafs(value);
let leaves = all_leaves(value);
let mut vec = Vec::new();
for _ in 0..patches {
let mut ops = Vec::new();
for _ in 0..operations {
let path = leafs.choose(rnd).unwrap();
let path = leaves.choose(rnd).unwrap();
ops.push(PatchOperation::Remove(RemoveOperation {
path: (*path).clone(),
}));
Expand All @@ -98,25 +98,25 @@ pub fn gen_add_remove_patches<R: Rng>(
vec
}

fn all_leafs(value: &Value) -> Vec<Pointer> {
fn all_leaves(value: &Value) -> Vec<Pointer> {
let mut result = Vec::new();
collect_leafs(value, &mut Pointer::root(), &mut result);
collect_leaves(value, &mut Pointer::root(), &mut result);
result
}

fn collect_leafs(value: &Value, prefix: &mut Pointer, result: &mut Vec<Pointer>) {
fn collect_leaves(value: &Value, prefix: &mut Pointer, result: &mut Vec<Pointer>) {
match *value {
Value::Array(ref arr) => {
for (idx, val) in arr.iter().enumerate() {
prefix.push_back(idx.into());
collect_leafs(val, prefix, result);
collect_leaves(val, prefix, result);
prefix.pop_back();
}
}
Value::Object(ref map) => {
for (key, val) in map.iter() {
prefix.push_back(key.into());
collect_leafs(val, prefix, result);
collect_leaves(val, prefix, result);
prefix.pop_back();
}
}
Expand Down
Loading