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

Use a union to reduce the size of SmallVec [v2] #94

Merged
merged 4 commits into from
Jun 6, 2018
Merged
Show file tree
Hide file tree
Changes from 3 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
3 changes: 1 addition & 2 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,9 @@ rust:
- stable
script: |
cargo build --verbose &&
cargo build --all-features --verbose &&
cargo test --verbose &&
cargo test --all-features --verbose &&
([ $TRAVIS_RUST_VERSION != nightly ] || cargo test --verbose --no-default-features) &&
([ $TRAVIS_RUST_VERSION != nightly ] || cargo test --verbose --features union) &&
([ $TRAVIS_RUST_VERSION != nightly ] || cargo bench --verbose bench)
notifications:
webhooks: http://build.servo.org:54856/travis
3 changes: 3 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,16 @@ documentation = "http://doc.servo.org/smallvec/"

[features]
std = []
union = []
default = ["std"]

[lib]
name = "smallvec"
path = "lib.rs"

[dependencies]
unreachable = "1.0.0"
debug_unreachable = "0.1"
Copy link
Collaborator

Choose a reason for hiding this comment

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

We may not want to use debug_unreachable, because it is unmaintained and doesn't work correctly in Rust > 1.0: reem/rust-debug-unreachable#6

We could just use unreachable all the time, or write our own debug_unreachable macro, or write a new debug_unreachable-like crate...

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Makes sense, I'll remove the dependency and add the equivalent macro.

serde = { version = "1", optional = true }

[dev_dependencies]
Expand Down
6 changes: 3 additions & 3 deletions benches/bench.rs
Original file line number Diff line number Diff line change
Expand Up @@ -158,15 +158,15 @@ fn gen_insert<V: Vector<u64>>(n: u64, b: &mut Bencher) {

fn gen_remove<V: Vector<u64>>(n: usize, b: &mut Bencher) {
#[inline(never)]
fn remove_noinline<V: Vector<u64>>(vec: &mut V, p: usize) {
vec.remove(p);
fn remove_noinline<V: Vector<u64>>(vec: &mut V, p: usize) -> u64 {
vec.remove(p)
}

b.iter(|| {
let mut vec = V::from_elem(0, n as _);

for x in (0..n - 1).rev() {
remove_noinline(&mut vec, x)
remove_noinline(&mut vec, x);
}
});
}
Expand Down
Loading