Commit Graph

341 Commits

Author SHA1 Message Date
Matt Brubeck dbe47a7e58 Document Cargo features 2020-04-05 19:13:15 -07:00
Matt Brubeck b613bc48c2 Make ToSmallVec trait public 2020-04-05 17:33:35 -07:00
bors-servo 88c32dfc0e Auto merge of #206 - hiddenhare:inline-constructors, r=mbrubeck
Add #[inline] attribute to all fns which return SmallVec

When rustc fails to inline a `SmallVec` constructor, it can carry a significant performance cost: for example, if `SmallVec::<[i64; 128]>::from_iter(...)` fails to inline, it will perform an unnecessary 1kb memcpy.

I've recently been bitten by this when using `SmallVec` in a context where rustc seemed to be reluctant to perform inlining (a large fn with nested closures). Switching from `SmallVec::from_iter` to `SmallVec::new` and `push`, with a buffer size of 256 bytes, saved over 20ns per call. For larger buffers, `from_iter` carried a proportionally higher cost, even when the actual capacity in use didn't change.
2020-04-05 00:43:32 -04:00
hiddenhare 402db2503a Add #[inline] attribute to all fns which return SmallVec 2020-04-04 11:37:58 +01:00
bors-servo beae6234a7 Auto merge of #204 - c410-f3r:const__generics, r=mbrubeck
Add support for constant generics

No breaking changes and no internal hacks. This PR only adds a feature to switch between implementations of the `Array` trait.

I personally think that this approach is pretty reasonable and should be at least considered for discussion.
2020-03-18 01:34:05 -04:00
bors-servo 14576573f3 Auto merge of #205 - c410-f3r:fix-ci, r=mbrubeck
Fix CI

Pin `cargo install honggfuzz` version to match the same version of `Cargo.toml`
2020-03-17 22:44:45 -04:00
Caio bcfe84a5fa Fix CI 2020-03-17 19:32:21 -03:00
Caio 33f69cd0a6 Add support for constant generics 2020-03-17 17:37:31 -03:00
bors-servo 60747139cd Auto merge of #203 - UnicodingUnicorn:add-to_smallvec-to-slice, r=mbrubeck
added to_smallvec extension trait to slice primitive

Should resolve #116.
2020-02-24 11:00:57 -05:00
UnicodingUnicorn fb032e2533 added to_smallvec extension trait to slice primitive 2020-02-21 23:12:51 +08:00
bors-servo 1be529bcaa Auto merge of #199 - mbrubeck:bump, r=emilio
Version 1.2.0

Changes in this release:

* `IntoIter` now implements `Debug` (#196).
* `smallvec!` macro is now easier to use in `no_std` contexts where the `vec!` macro isn't automatically imported (#198).
2020-01-28 18:17:40 -05:00
Matt Brubeck c76230e526 Version 1.2.0
Changes in this release:

* `IntoIter` now implments `Debug` (#196).
* `smallvec!` macro is now easier to use in `no_std` contexts
   where the `vec!` macro isn't automatically imported (#198).
2020-01-27 20:27:28 -08:00
bors-servo 62781ba96e Auto merge of #198 - mbrubeck:macro, r=jdm
Use full path to vec! in smallvec! macro

Fixes #197
2020-01-27 19:03:35 -05:00
Matt Brubeck 8407c17332 Use full path to vec! in smallvec! macro
Fixes #197
2020-01-27 09:55:30 -08:00
bors-servo 91ef96cc6f Auto merge of #196 - Nemo157:intoiter-debug, r=mbrubeck
impl Debug for IntoIter

This has long been provided by `std::vec::IntoIter`, so is useful in cases where it is being directly replaced.
2020-01-27 11:53:57 -05:00
Wim Looman d930048d8d impl Debug for IntoIter 2020-01-24 14:09:20 +01:00
bors-servo 2bcd0c799a Auto merge of #193 - mbrubeck:bump, r=emilio
Version 1.1.0

Changes in this release:

* Added new method `SmallVec::into_boxed_slice` (#190).
* Added new methods `IntoIter::as_slice` and `as_mut_slice` (#182).
* `IntoIter` now implements `Clone` (#192).
* Improved documentation and testing (#186, #189).
* Minor code cleanups (#176).

Also added a simple example to the README.
2019-12-20 17:04:48 -05:00
Matt Brubeck 23f6f7da38 Version 1.1.0
Changes in this release:

* Added new method `SmallVec::into_boxed_slice` (#190).
* Added new method `IntoIter::as_slice` (#182).
* `IntoIter` now implements `Clone` (#192).
* Improved documentation and testing (#186, #189).
* Minor code cleanups (#176).
2019-12-19 08:33:51 -08:00
Matt Brubeck 9bface622a Add a simple example to the README 2019-12-19 08:33:51 -08:00
bors-servo aa7ecd051d Auto merge of #192 - L0uisc:clone-into-iter, r=mbrubeck
Implement Clone for IntoIter<A> where A: Clone

Implemented code to fix #178. The commented impl can be uncommented once specialization is possible. Both impls were tested and passed the three added tests.
2019-12-13 18:20:39 -05:00
L0uisc 209af2201d Remove specialized impl 2019-12-13 20:54:01 +02:00
L0uisc d116e267d6 Implement Clone for IntoIter<A> where A: Clone 2019-12-12 23:15:18 +02:00
bors-servo 8310c426f2 Auto merge of #190 - L0uisc:into-boxed-slice, r=mbrubeck
Implement into_boxed_slice() and doc-comment it.

Implements `into_boxed_slice()` as per suggestion in #184.

I didn't write tests, since all I did was to call an existing method of `SmallVec`, `into_vec()` to create a `Vec` from it and then call a method of `alloc::vec::Vec`, `into_boxed_slice()` on the resulting `Vec`. Thus, nothing in my code needs testing, since it is trivially offloading to other methods.

I didn't, however, find a test exercising `into_vec()`, however. That is maybe something I can do? If so, can I get some pointers to where I should look for example tests and where my tests should live?

EDIT: Never mind, I forgot that unit tests are in the same file, so I scrutinized smallvec_ops.rs to search for a test for `into_vec()` and couldn't find it.
2019-12-11 16:48:59 -05:00
L0uisc d9b9228da5 Implement into_boxed_slice() and doc-comment it. 2019-12-11 21:38:56 +02:00
bors-servo d604f6010b Auto merge of #189 - mbrubeck:docs, r=jdm
Remove outdated no_std docs

None
2019-12-11 09:42:07 -05:00
Matt Brubeck a7820b22c9 Remove outdated no_std docs 2019-12-11 06:34:27 -08:00
bors-servo f5c2e9a766 Auto merge of #188 - mbrubeck:docs, r=jdm
Link to docs.rs for documentation

because doc.servo.org might not always have the same version as crates.io
2019-12-10 13:11:37 -05:00
Matt Brubeck bd1fc73734 Link to docs.rs for documentation 2019-12-10 09:18:54 -08:00
bors-servo 3eac78f319 Auto merge of #186 - RalfJung:miri, r=mbrubeck
Miri now supports catching panics

Also fix a mistake in the .gitignore (at least on my system, this didn't actually ignore the lockfile)
2019-12-09 14:11:08 -05:00
Ralf Jung d8e1988ce2 ignore memory leaks 2019-12-09 18:16:07 +01:00
Ralf Jung 379c322429 enable more tests in Miri and fix sue of 'std' feature 2019-12-07 12:08:15 +01:00
Ralf Jung 289606f1d8 Miri now supports catching panics 2019-12-06 09:41:14 +01:00
bors-servo b47757b3ac Auto merge of #182 - rklaehn:add-iter-as-slice, r=mbrubeck
Add as_slice and as_mut_slice methods

To allow random access for remaining data in smallvec::IntoIter, just like
std::vec::IntoIter

Implements https://github.com/servo/rust-smallvec/issues/181
2019-11-16 12:10:32 -05:00
Rüdiger Klaehn be3ade83c4 Add as_slice and as_mut_slice methods
To allow random access for remaining data in smallvec::IntoIter, just like
std::vec::IntoIter

Implements https://github.com/servo/rust-smallvec/issues/181
2019-11-16 14:19:24 +01:00
bors-servo 254c590d2d Auto merge of #176 - mbrubeck:cleanup, r=emilio
Some code cleanups

Apply some clippy suggestions, and revert a failed optimization.
2019-11-03 17:56:14 -05:00
bors-servo 2f99776ea1 Auto merge of #175 - mbrubeck:one, r=jdm
Version 1.0.0

* Requires Rust 1.36 or later.
* [breaking change] Use `MaybeUninit` to avoid possible undefined behavior (#162, #170).
* [breaking change] The `drain` method now takes a range argument, just like the standard `Vec::drain` (#145).
* [breaking change] Remove the `unreachable` function and replace it with the new standard `unreachable_unchecked` function (#164).
* [breaking change] Use `no_std` by default. This crate depends only on `core` and `alloc` by default. If the optional `write` feature is enabled then it depends on `std` so that `SmallVec<[u8;_]>` can implement the `std::io::Write` trait (#173).
* Add support for 96-element small vectors, `SmallVec<[T; 96]>` (#163).
* Iterators now implement `FusedIterator` (#172).
* Indexing now uses the standard `SliceIndex` trait (#166).
* Remove the deprecated `VecLike` trait (#165).
* Use `NonNull` internally (#171).
* Add automatic fuzz testing and MIRI testing (#168, #162).
* Update syntax and formatting to Rust 2018 standard (#174, #167).
2019-11-02 16:25:35 -04:00
Matt Brubeck a45ca9ab0d Revert "Make use of NonNull"
This reverts commit 031b6d57f8.

This didn't actually provide any size optimization benefits, and the
code is slightly simpler without it.
2019-10-31 09:24:14 -07:00
Matt Brubeck dfbb70ce02 Minor code clean-ups
as suggested by clippy
2019-10-31 09:13:55 -07:00
Matt Brubeck 08cb56d4dc Version 1.0.0
* [breaking change] Use `MaybeUninit` internally to avoid possible undefined behavior (#162, #170).
* [breaking change] The `drain` method now takes a range argument, just like the standard `Vec::drain` (#145).
* [breaking change] Remove the `unreachable` function and replace it with the new standard `unreachable_unchecked` function (#164).
* [breaking change] Use `no_std` by default. This crate depends only on `core` and `alloc` by default. If the optional `write` feature is enabled then it depends on `std` so that `SmallVec<[u8, _]>` can implement the `std::io::Write` trait (#173).
* Add support for 96-element small vectors, `SmallVec<[T; 96]>` (#163).
* Iterators now implement `FusedIterator` (#172).
* Indexing now uses the standard `SliceIndex` trait (#166).
* Remove the deprecated `VecLike` trait (#165).
* Use `NonNull` internally (#171).
* Add automatic fuzz testing and MIRI testing (#168, #162).
* Update syntax and formatting to Rust 2018 standard (#174, #167).
2019-10-30 14:05:50 -07:00
bors-servo a8495673a1 Auto merge of #174 - mbrubeck:2018, r=jdm
Update to Rust 2018 edition

None
2019-10-30 15:40:53 -04:00
Matt Brubeck 0707ebdf3c Update to Rust 2018 edition 2019-10-30 12:10:47 -07:00
bors-servo 6a223572e0 Auto merge of #168 - dpc:fuzz, r=mbrubeck
Add simple fuzzing

Add simple fuzzing

Add infrastructure to automatically run fuzzers in CI,
and implement a simple fuzzing test based on triggering all (most)
public APIs in a randimized way.

As far as I was able to try, it catches the previous unsoundness issues
in a matter of seconds. This can be tried by changing the `path = "../"` dependency to
`version = "=0.6.3"` etc. and running the fuzzer manually. (Note: You'll need
to tweak the `Cargo.lock` to allow downloading the yanked versions).
2019-10-30 15:03:57 -04:00
Dawid Ciężarkiewicz 3587972a26 Add a fake stub input case for afl fuzzer 2019-10-29 21:36:59 -07:00
Dawid Ciężarkiewicz 47028a7e02 Add simple fuzzing
Add infrastructure to automatically run fuzzers in CI,
and implement a simple fuzzing test based on triggering all (most)
public APIs in a randimized way.

As far as I was able to try it catches the previous unsoundness issues
in a matter of seconds. This can be tried by changing the `path = "../"` dependency to
`version = "=0.6.3"` etc. and running the fuzzer manually. (Note: You'll need
to tweak the `Cargo.lock` to allow downloading the yanked versions).

Related to #124
2019-10-29 21:36:59 -07:00
bors-servo 782dd470bd Auto merge of #173 - mbrubeck:std, r=emilio
Use no_std by default

Since `alloc` became stable, the `std` feature is only needed to enable `impl Write for SmallVec`, which most users of this crate do not need.  This patch replaces the enabled-by-default `std` feature with a disabled-by-default `write` feature.  This decreases the chance that users of this crate will accidentally depend on libstd when they don't need it.
2019-10-29 17:30:35 -04:00
Matt Brubeck 9940efa341 Use no_std by default
The `std` feature is only needed to enable `impl Write for SmallVec`,
which most users of this crate do not need.  This patch replaces the
enabled-by-default `std` feature with a disabled-by-default `write`
feature.  This decreases the chance that users of this crate will
accidentally depend on libstd when they don't need it.
2019-10-29 10:57:22 -07:00
bors-servo 496432a739 Auto merge of #172 - mbrubeck:fused, r=mbrubeck
Implement `FusedIterator` for `IntoIter`

Rebase of #143
2019-10-28 19:58:35 -04:00
Jan Bujak eb79ecff44 Implement FusedIterator for IntoIter 2019-10-28 16:55:08 -07:00
bors-servo c2bc09b8da Auto merge of #171 - mbrubeck:nonnull, r=mbrubeck
Use NonNull instead of a raw pointer

This may reduce space requiments due to the null pointer optimization.
2019-10-28 19:40:57 -04:00
Caio 031b6d57f8 Make use of NonNull 2019-10-28 16:39:13 -07:00