Skip to content

Commit

Permalink
fix: replace source should hash inner source (#60)
Browse files Browse the repository at this point in the history
* fix: replace source should hash inner source

* fix test

---------

Co-authored-by: ahabhgk <[email protected]>
  • Loading branch information
underfin and ahabhgk authored Jun 12, 2023
1 parent 81ee4e2 commit c417331
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
5 changes: 3 additions & 2 deletions src/replace_source.rs
Original file line number Diff line number Diff line change
Expand Up @@ -547,8 +547,9 @@ impl<T: Hash> Hash for ReplaceSource<T> {
self.sort_replacement();
"ReplaceSource".hash(state);
for repl in self.replacements.lock().iter() {
repl.hash(state)
repl.hash(state);
}
self.inner.hash(state);
}
}

Expand Down Expand Up @@ -962,7 +963,7 @@ return <div>{data.foo}</div>
assert_eq!(source.map(&MapOptions::default()), None);
let mut hasher = twox_hash::XxHash64::default();
source.hash(&mut hasher);
assert_eq!(format!("{:x}", hasher.finish()), "ab891b4c45dc95b4");
assert_eq!(format!("{:x}", hasher.finish()), "e9877250d7449bc5");
}

#[test]
Expand Down
2 changes: 1 addition & 1 deletion src/source.rs
Original file line number Diff line number Diff line change
Expand Up @@ -532,7 +532,7 @@ mod tests {
RawSource::from("g").boxed().hash(&mut state);
(&RawSource::from("h") as &dyn Source).hash(&mut state);
ReplaceSource::new(RawSource::from("i").boxed()).hash(&mut state);
assert_eq!(format!("{:x}", state.finish()), "940ec870b6ce313a");
assert_eq!(format!("{:x}", state.finish()), "fb814b430ddd31e0");
}

#[test]
Expand Down

1 comment on commit c417331

@github-actions
Copy link

Choose a reason for hiding this comment

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

Benchmark

Benchmark suite Current: c417331 Previous: fbbc1c2 Ratio
benchmark_concat_generate_base64 28553 ns/iter (± 184) 23621 ns/iter (± 274) 1.21
benchmark_concat_generate_base64_with_cache 18136 ns/iter (± 118) 15088 ns/iter (± 72) 1.20
benchmark_concat_generate_string 14390 ns/iter (± 92) 11898 ns/iter (± 145) 1.21
benchmark_concat_generate_string_with_cache 4079 ns/iter (± 69) 3382 ns/iter (± 15) 1.21

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

Please sign in to comment.