Skip to content

Commit

Permalink
fix clone regression
Browse files Browse the repository at this point in the history
test bench::bench_derive_clone ... bench:     454,318 ns/iter (+/- 11,401)
test bench::bench_match_clone  ... bench:     183,570 ns/iter (+/- 10,652)
test bench::bench_new_clone    ... bench:     177,907 ns/iter (+/- 2,234)
  • Loading branch information
AntonSol919 authored and Veykril committed Jan 31, 2024
1 parent 14cbe54 commit d5994d5
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -503,12 +503,12 @@ enum InlineSize {

#[derive(Clone, Debug)]
enum Repr {
Heap(Arc<str>),
Static(&'static str),
Inline {
len: InlineSize,
buf: [u8; INLINE_CAP],
},
Static(&'static str),
Heap(Arc<str>),
}

impl Repr {
Expand Down

1 comment on commit d5994d5

@novacrazy
Copy link
Contributor

Choose a reason for hiding this comment

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

I may be wrong, but I don't think the order of enum variants is guaranteed under #[repr(Rust)] (the default). This may have provided a small benefit today, but may be rearranged by the compiler at any point. It may even be affected by how you use the enum whether it rearranges or not. Might be worth checking if #[repr(C)] can work here.

Please sign in to comment.