Coverage Report

Created: 2026-02-14 07:02

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/rust/registry/src/index.crates.io-1949cf8c6b5b557f/smallvec-1.9.0/src/lib.rs
Line
Count
Source
1
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
2
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
3
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
4
// option. This file may not be copied, modified, or distributed
5
// except according to those terms.
6
7
//! Small vectors in various sizes. These store a certain number of elements inline, and fall back
8
//! to the heap for larger allocations.  This can be a useful optimization for improving cache
9
//! locality and reducing allocator traffic for workloads that fit within the inline buffer.
10
//!
11
//! ## `no_std` support
12
//!
13
//! By default, `smallvec` does not depend on `std`.  However, the optional
14
//! `write` feature implements the `std::io::Write` trait for vectors of `u8`.
15
//! When this feature is enabled, `smallvec` depends on `std`.
16
//!
17
//! ## Optional features
18
//!
19
//! ### `serde`
20
//!
21
//! When this optional dependency is enabled, `SmallVec` implements the `serde::Serialize` and
22
//! `serde::Deserialize` traits.
23
//!
24
//! ### `write`
25
//!
26
//! When this feature is enabled, `SmallVec<[u8; _]>` implements the `std::io::Write` trait.
27
//! This feature is not compatible with `#![no_std]` programs.
28
//!
29
//! ### `union`
30
//!
31
//! **This feature requires Rust 1.49.**
32
//!
33
//! When the `union` feature is enabled `smallvec` will track its state (inline or spilled)
34
//! without the use of an enum tag, reducing the size of the `smallvec` by one machine word.
35
//! This means that there is potentially no space overhead compared to `Vec`.
36
//! Note that `smallvec` can still be larger than `Vec` if the inline buffer is larger than two
37
//! machine words.
38
//!
39
//! To use this feature add `features = ["union"]` in the `smallvec` section of Cargo.toml.
40
//! Note that this feature requires Rust 1.49.
41
//!
42
//! Tracking issue: [rust-lang/rust#55149](https://github.com/rust-lang/rust/issues/55149)
43
//!
44
//! ### `const_generics`
45
//!
46
//! **This feature requires Rust 1.51.**
47
//!
48
//! When this feature is enabled, `SmallVec` works with any arrays of any size, not just a fixed
49
//! list of sizes.
50
//!
51
//! ### `const_new`
52
//!
53
//! **This feature requires Rust 1.51.**
54
//!
55
//! This feature exposes the functions [`SmallVec::new_const`], [`SmallVec::from_const`], and [`smallvec_inline`] which enables the `SmallVec` to be initialized from a const context.
56
//! For details, see the
57
//! [Rust Reference](https://doc.rust-lang.org/reference/const_eval.html#const-functions).
58
//!
59
//! ### `specialization`
60
//!
61
//! **This feature is unstable and requires a nightly build of the Rust toolchain.**
62
//!
63
//! When this feature is enabled, `SmallVec::from(slice)` has improved performance for slices
64
//! of `Copy` types.  (Without this feature, you can use `SmallVec::from_slice` to get optimal
65
//! performance for `Copy` types.)
66
//!
67
//! Tracking issue: [rust-lang/rust#31844](https://github.com/rust-lang/rust/issues/31844)
68
//!
69
//! ### `may_dangle`
70
//!
71
//! **This feature is unstable and requires a nightly build of the Rust toolchain.**
72
//!
73
//! This feature makes the Rust compiler less strict about use of vectors that contain borrowed
74
//! references. For details, see the
75
//! [Rustonomicon](https://doc.rust-lang.org/1.42.0/nomicon/dropck.html#an-escape-hatch).
76
//!
77
//! Tracking issue: [rust-lang/rust#34761](https://github.com/rust-lang/rust/issues/34761)
78
79
#![no_std]
80
#![cfg_attr(docsrs, feature(doc_cfg))]
81
#![cfg_attr(feature = "specialization", allow(incomplete_features))]
82
#![cfg_attr(feature = "specialization", feature(specialization))]
83
#![cfg_attr(feature = "may_dangle", feature(dropck_eyepatch))]
84
#![deny(missing_docs)]
85
86
#[doc(hidden)]
87
pub extern crate alloc;
88
89
#[cfg(any(test, feature = "write"))]
90
extern crate std;
91
92
#[cfg(test)]
93
mod tests;
94
95
#[allow(deprecated)]
96
use alloc::alloc::{Layout, LayoutErr};
97
use alloc::boxed::Box;
98
use alloc::{vec, vec::Vec};
99
use core::borrow::{Borrow, BorrowMut};
100
use core::cmp;
101
use core::fmt;
102
use core::hash::{Hash, Hasher};
103
use core::hint::unreachable_unchecked;
104
use core::iter::{repeat, FromIterator, FusedIterator, IntoIterator};
105
use core::mem;
106
use core::mem::MaybeUninit;
107
use core::ops::{self, Range, RangeBounds};
108
use core::ptr::{self, NonNull};
109
use core::slice::{self, SliceIndex};
110
111
#[cfg(feature = "serde")]
112
use serde::{
113
    de::{Deserialize, Deserializer, SeqAccess, Visitor},
114
    ser::{Serialize, SerializeSeq, Serializer},
115
};
116
117
#[cfg(feature = "serde")]
118
use core::marker::PhantomData;
119
120
#[cfg(feature = "write")]
121
use std::io;
122
123
/// Creates a [`SmallVec`] containing the arguments.
124
///
125
/// `smallvec!` allows `SmallVec`s to be defined with the same syntax as array expressions.
126
/// There are two forms of this macro:
127
///
128
/// - Create a [`SmallVec`] containing a given list of elements:
129
///
130
/// ```
131
/// # #[macro_use] extern crate smallvec;
132
/// # use smallvec::SmallVec;
133
/// # fn main() {
134
/// let v: SmallVec<[_; 128]> = smallvec![1, 2, 3];
135
/// assert_eq!(v[0], 1);
136
/// assert_eq!(v[1], 2);
137
/// assert_eq!(v[2], 3);
138
/// # }
139
/// ```
140
///
141
/// - Create a [`SmallVec`] from a given element and size:
142
///
143
/// ```
144
/// # #[macro_use] extern crate smallvec;
145
/// # use smallvec::SmallVec;
146
/// # fn main() {
147
/// let v: SmallVec<[_; 0x8000]> = smallvec![1; 3];
148
/// assert_eq!(v, SmallVec::from_buf([1, 1, 1]));
149
/// # }
150
/// ```
151
///
152
/// Note that unlike array expressions this syntax supports all elements
153
/// which implement [`Clone`] and the number of elements doesn't have to be
154
/// a constant.
155
///
156
/// This will use `clone` to duplicate an expression, so one should be careful
157
/// using this with types having a nonstandard `Clone` implementation. For
158
/// example, `smallvec![Rc::new(1); 5]` will create a vector of five references
159
/// to the same boxed integer value, not five references pointing to independently
160
/// boxed integers.
161
162
#[macro_export]
163
macro_rules! smallvec {
164
    // count helper: transform any expression into 1
165
    (@one $x:expr) => (1usize);
166
    ($elem:expr; $n:expr) => ({
167
        $crate::SmallVec::from_elem($elem, $n)
168
    });
169
    ($($x:expr),*$(,)*) => ({
170
        let count = 0usize $(+ $crate::smallvec!(@one $x))*;
171
        #[allow(unused_mut)]
172
        let mut vec = $crate::SmallVec::new();
173
        if count <= vec.inline_size() {
174
            $(vec.push($x);)*
175
            vec
176
        } else {
177
            $crate::SmallVec::from_vec($crate::alloc::vec![$($x,)*])
178
        }
179
    });
180
}
181
182
/// Creates an inline [`SmallVec`] containing the arguments. This macro is enabled by the feature `const_new`.
183
///
184
/// `smallvec_inline!` allows `SmallVec`s to be defined with the same syntax as array expressions in `const` contexts.
185
/// The inline storage `A` will always be an array of the size specified by the arguments.
186
/// There are two forms of this macro:
187
///
188
/// - Create a [`SmallVec`] containing a given list of elements:
189
///
190
/// ```
191
/// # #[macro_use] extern crate smallvec;
192
/// # use smallvec::SmallVec;
193
/// # fn main() {
194
/// const V: SmallVec<[i32; 3]> = smallvec_inline![1, 2, 3];
195
/// assert_eq!(V[0], 1);
196
/// assert_eq!(V[1], 2);
197
/// assert_eq!(V[2], 3);
198
/// # }
199
/// ```
200
///
201
/// - Create a [`SmallVec`] from a given element and size:
202
///
203
/// ```
204
/// # #[macro_use] extern crate smallvec;
205
/// # use smallvec::SmallVec;
206
/// # fn main() {
207
/// const V: SmallVec<[i32; 3]> = smallvec_inline![1; 3];
208
/// assert_eq!(V, SmallVec::from_buf([1, 1, 1]));
209
/// # }
210
/// ```
211
///
212
/// Note that the behavior mimics that of array expressions, in contrast to [`smallvec`].
213
#[cfg(feature = "const_new")]
214
#[cfg_attr(docsrs, doc(cfg(feature = "const_new")))]
215
#[macro_export]
216
macro_rules! smallvec_inline {
217
    // count helper: transform any expression into 1
218
    (@one $x:expr) => (1usize);
219
    ($elem:expr; $n:expr) => ({
220
        $crate::SmallVec::<[_; $n]>::from_const([$elem; $n])
221
    });
222
    ($($x:expr),+ $(,)?) => ({
223
        const N: usize = 0usize $(+ $crate::smallvec_inline!(@one $x))*;
224
        $crate::SmallVec::<[_; N]>::from_const([$($x,)*])
225
    });
226
}
227
228
/// `panic!()` in debug builds, optimization hint in release.
229
#[cfg(not(feature = "union"))]
230
macro_rules! debug_unreachable {
231
    () => {
232
        debug_unreachable!("entered unreachable code")
233
    };
234
    ($e:expr) => {
235
        if cfg!(not(debug_assertions)) {
236
            unreachable_unchecked();
237
        } else {
238
            panic!($e);
239
        }
240
    };
241
}
242
243
/// Trait to be implemented by a collection that can be extended from a slice
244
///
245
/// ## Example
246
///
247
/// ```rust
248
/// use smallvec::{ExtendFromSlice, SmallVec};
249
///
250
/// fn initialize<V: ExtendFromSlice<u8>>(v: &mut V) {
251
///     v.extend_from_slice(b"Test!");
252
/// }
253
///
254
/// let mut vec = Vec::new();
255
/// initialize(&mut vec);
256
/// assert_eq!(&vec, b"Test!");
257
///
258
/// let mut small_vec = SmallVec::<[u8; 8]>::new();
259
/// initialize(&mut small_vec);
260
/// assert_eq!(&small_vec as &[_], b"Test!");
261
/// ```
262
#[doc(hidden)]
263
#[deprecated]
264
pub trait ExtendFromSlice<T> {
265
    /// Extends a collection from a slice of its element type
266
    fn extend_from_slice(&mut self, other: &[T]);
267
}
268
269
#[allow(deprecated)]
270
impl<T: Clone> ExtendFromSlice<T> for Vec<T> {
271
0
    fn extend_from_slice(&mut self, other: &[T]) {
272
0
        Vec::extend_from_slice(self, other)
273
0
    }
274
}
275
276
/// Error type for APIs with fallible heap allocation
277
#[derive(Debug)]
278
pub enum CollectionAllocErr {
279
    /// Overflow `usize::MAX` or other error during size computation
280
    CapacityOverflow,
281
    /// The allocator return an error
282
    AllocErr {
283
        /// The layout that was passed to the allocator
284
        layout: Layout,
285
    },
286
}
287
288
impl fmt::Display for CollectionAllocErr {
289
0
    fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
290
0
        write!(f, "Allocation error: {:?}", self)
291
0
    }
292
}
293
294
#[allow(deprecated)]
295
impl From<LayoutErr> for CollectionAllocErr {
296
0
    fn from(_: LayoutErr) -> Self {
297
0
        CollectionAllocErr::CapacityOverflow
298
0
    }
299
}
300
301
1.12M
fn infallible<T>(result: Result<T, CollectionAllocErr>) -> T {
302
0
    match result {
303
1.12M
        Ok(x) => x,
304
0
        Err(CollectionAllocErr::CapacityOverflow) => panic!("capacity overflow"),
305
0
        Err(CollectionAllocErr::AllocErr { layout }) => alloc::alloc::handle_alloc_error(layout),
306
    }
307
1.12M
}
Unexecuted instantiation: smallvec::infallible::<_>
smallvec::infallible::<()>
Line
Count
Source
301
1.12M
fn infallible<T>(result: Result<T, CollectionAllocErr>) -> T {
302
0
    match result {
303
1.12M
        Ok(x) => x,
304
0
        Err(CollectionAllocErr::CapacityOverflow) => panic!("capacity overflow"),
305
0
        Err(CollectionAllocErr::AllocErr { layout }) => alloc::alloc::handle_alloc_error(layout),
306
    }
307
1.12M
}
Unexecuted instantiation: smallvec::infallible::<()>
308
309
/// FIXME: use `Layout::array` when we require a Rust version where it’s stable
310
/// https://github.com/rust-lang/rust/issues/55724
311
235k
fn layout_array<T>(n: usize) -> Result<Layout, CollectionAllocErr> {
312
235k
    let size = mem::size_of::<T>()
313
235k
        .checked_mul(n)
314
235k
        .ok_or(CollectionAllocErr::CapacityOverflow)?;
315
235k
    let align = mem::align_of::<T>();
316
235k
    Layout::from_size_align(size, align).map_err(|_| CollectionAllocErr::CapacityOverflow)
317
235k
}
Unexecuted instantiation: smallvec::layout_array::<_>
Unexecuted instantiation: smallvec::layout_array::<base::wait_context::TriggeredEvent<<devices::serial::Serial>::spawn_input_thread::{closure#0}::Token>>
Unexecuted instantiation: smallvec::layout_array::<base::wait_context::TriggeredEvent<devices::bat::Token>>
Unexecuted instantiation: smallvec::layout_array::<base::wait_context::TriggeredEvent<devices::pit::Token>>
Unexecuted instantiation: smallvec::layout_array::<base::wait_context::TriggeredEvent<devices::virtio::console::worker::Token>>
Unexecuted instantiation: smallvec::layout_array::<base::wait_context::TriggeredEvent<<devices::vmwdt::Vmwdt>::vmwdt_worker_thread::Token>>
Unexecuted instantiation: smallvec::layout_array::<base::wait_context::TriggeredEvent<<devices::virtio::p9::Worker>::run::Token>>
Unexecuted instantiation: smallvec::layout_array::<base::wait_context::TriggeredEvent<<devices::virtio::rng::Worker>::run::Token>>
Unexecuted instantiation: smallvec::layout_array::<base::wait_context::TriggeredEvent<<devices::virtio::vhost_user_frontend::worker::Worker>::run::Token>>
Unexecuted instantiation: smallvec::layout_array::<base::wait_context::TriggeredEvent<<devices::virtio::vhost::worker::Worker<_>>::run::Token>>
Unexecuted instantiation: smallvec::layout_array::<base::wait_context::TriggeredEvent<<devices::pci::coiommu::PinWorker>::run::Token>>
Unexecuted instantiation: smallvec::layout_array::<base::wait_context::TriggeredEvent<<devices::pci::coiommu::UnpinWorker>::run::Token>>
Unexecuted instantiation: smallvec::layout_array::<base::wait_context::TriggeredEvent<<devices::pci::vfio_pci::VfioPciWorker>::run::Token>>
Unexecuted instantiation: smallvec::layout_array::<base::wait_context::TriggeredEvent<<devices::virtio::fs::worker::Worker<_>>::run::Token>>
Unexecuted instantiation: smallvec::layout_array::<base::wait_context::TriggeredEvent<<devices::virtio::wl::Worker>::run::Token>>
Unexecuted instantiation: smallvec::layout_array::<base::wait_context::TriggeredEvent<devices::virtcpufreq_v2::vcpufreq_worker_thread::Token>>
Unexecuted instantiation: smallvec::layout_array::<base::wait_context::TriggeredEvent<devices::acpi::run_worker::Token>>
Unexecuted instantiation: smallvec::layout_array::<base::wait_context::TriggeredEvent<devices::cmos::run_cmos_worker::Token>>
Unexecuted instantiation: smallvec::layout_array::<base::wait_context::TriggeredEvent<devices::virtio::interrupt::interrupt_resample_thread::Token>>
Unexecuted instantiation: smallvec::layout_array::<base::wait_context::TriggeredEvent<devices::virtio::console::sys::linux::read_input::Token>>
Unexecuted instantiation: smallvec::layout_array::<base::wait_context::TriggeredEvent<u32>>
Unexecuted instantiation: smallvec::layout_array::<base::volatile_memory::VolatileSlice>
smallvec::layout_array::<cros_async::mem::MemRegion>
Line
Count
Source
311
235k
fn layout_array<T>(n: usize) -> Result<Layout, CollectionAllocErr> {
312
235k
    let size = mem::size_of::<T>()
313
235k
        .checked_mul(n)
314
235k
        .ok_or(CollectionAllocErr::CapacityOverflow)?;
315
235k
    let align = mem::align_of::<T>();
316
235k
    Layout::from_size_align(size, align).map_err(|_| CollectionAllocErr::CapacityOverflow)
317
235k
}
Unexecuted instantiation: smallvec::layout_array::<base::wait_context::TriggeredEvent<metrics::controller::MetricsControllerToken>>
Unexecuted instantiation: smallvec::layout_array::<base::wait_context::TriggeredEvent<usize>>
318
319
0
unsafe fn deallocate<T>(ptr: *mut T, capacity: usize) {
320
    // This unwrap should succeed since the same did when allocating.
321
0
    let layout = layout_array::<T>(capacity).unwrap();
322
0
    alloc::alloc::dealloc(ptr as *mut u8, layout)
323
0
}
Unexecuted instantiation: smallvec::deallocate::<_>
Unexecuted instantiation: smallvec::deallocate::<base::wait_context::TriggeredEvent<<devices::serial::Serial>::spawn_input_thread::{closure#0}::Token>>
Unexecuted instantiation: smallvec::deallocate::<base::wait_context::TriggeredEvent<devices::bat::Token>>
Unexecuted instantiation: smallvec::deallocate::<base::wait_context::TriggeredEvent<devices::pit::Token>>
Unexecuted instantiation: smallvec::deallocate::<base::wait_context::TriggeredEvent<devices::virtio::console::worker::Token>>
Unexecuted instantiation: smallvec::deallocate::<base::wait_context::TriggeredEvent<<devices::vmwdt::Vmwdt>::vmwdt_worker_thread::Token>>
Unexecuted instantiation: smallvec::deallocate::<base::wait_context::TriggeredEvent<<devices::virtio::p9::Worker>::run::Token>>
Unexecuted instantiation: smallvec::deallocate::<base::wait_context::TriggeredEvent<<devices::virtio::rng::Worker>::run::Token>>
Unexecuted instantiation: smallvec::deallocate::<base::wait_context::TriggeredEvent<<devices::virtio::vhost_user_frontend::worker::Worker>::run::Token>>
Unexecuted instantiation: smallvec::deallocate::<base::wait_context::TriggeredEvent<<devices::virtio::vhost::worker::Worker<_>>::run::Token>>
Unexecuted instantiation: smallvec::deallocate::<base::wait_context::TriggeredEvent<<devices::pci::coiommu::PinWorker>::run::Token>>
Unexecuted instantiation: smallvec::deallocate::<base::wait_context::TriggeredEvent<<devices::pci::coiommu::UnpinWorker>::run::Token>>
Unexecuted instantiation: smallvec::deallocate::<base::wait_context::TriggeredEvent<<devices::pci::vfio_pci::VfioPciWorker>::run::Token>>
Unexecuted instantiation: smallvec::deallocate::<base::wait_context::TriggeredEvent<<devices::virtio::fs::worker::Worker<_>>::run::Token>>
Unexecuted instantiation: smallvec::deallocate::<base::wait_context::TriggeredEvent<<devices::virtio::wl::Worker>::run::Token>>
Unexecuted instantiation: smallvec::deallocate::<base::wait_context::TriggeredEvent<devices::virtcpufreq_v2::vcpufreq_worker_thread::Token>>
Unexecuted instantiation: smallvec::deallocate::<base::wait_context::TriggeredEvent<devices::acpi::run_worker::Token>>
Unexecuted instantiation: smallvec::deallocate::<base::wait_context::TriggeredEvent<devices::cmos::run_cmos_worker::Token>>
Unexecuted instantiation: smallvec::deallocate::<base::wait_context::TriggeredEvent<devices::virtio::interrupt::interrupt_resample_thread::Token>>
Unexecuted instantiation: smallvec::deallocate::<base::wait_context::TriggeredEvent<devices::virtio::console::sys::linux::read_input::Token>>
Unexecuted instantiation: smallvec::deallocate::<base::wait_context::TriggeredEvent<u32>>
Unexecuted instantiation: smallvec::deallocate::<base::volatile_memory::VolatileSlice>
Unexecuted instantiation: smallvec::deallocate::<cros_async::mem::MemRegion>
Unexecuted instantiation: smallvec::deallocate::<base::wait_context::TriggeredEvent<metrics::controller::MetricsControllerToken>>
Unexecuted instantiation: smallvec::deallocate::<base::wait_context::TriggeredEvent<usize>>
324
325
/// An iterator that removes the items from a `SmallVec` and yields them by value.
326
///
327
/// Returned from [`SmallVec::drain`][1].
328
///
329
/// [1]: struct.SmallVec.html#method.drain
330
pub struct Drain<'a, T: 'a + Array> {
331
    tail_start: usize,
332
    tail_len: usize,
333
    iter: slice::Iter<'a, T::Item>,
334
    vec: NonNull<SmallVec<T>>,
335
}
336
337
impl<'a, T: 'a + Array> fmt::Debug for Drain<'a, T>
338
where
339
    T::Item: fmt::Debug,
340
{
341
0
    fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
342
0
        f.debug_tuple("Drain").field(&self.iter.as_slice()).finish()
343
0
    }
344
}
345
346
unsafe impl<'a, T: Sync + Array> Sync for Drain<'a, T> {}
347
unsafe impl<'a, T: Send + Array> Send for Drain<'a, T> {}
348
349
impl<'a, T: 'a + Array> Iterator for Drain<'a, T> {
350
    type Item = T::Item;
351
352
    #[inline]
353
0
    fn next(&mut self) -> Option<T::Item> {
354
0
        self.iter
355
0
            .next()
356
0
            .map(|reference| unsafe { ptr::read(reference) })
357
0
    }
358
359
    #[inline]
360
0
    fn size_hint(&self) -> (usize, Option<usize>) {
361
0
        self.iter.size_hint()
362
0
    }
363
}
364
365
impl<'a, T: 'a + Array> DoubleEndedIterator for Drain<'a, T> {
366
    #[inline]
367
0
    fn next_back(&mut self) -> Option<T::Item> {
368
0
        self.iter
369
0
            .next_back()
370
0
            .map(|reference| unsafe { ptr::read(reference) })
371
0
    }
372
}
373
374
impl<'a, T: Array> ExactSizeIterator for Drain<'a, T> {
375
    #[inline]
376
0
    fn len(&self) -> usize {
377
0
        self.iter.len()
378
0
    }
379
}
380
381
impl<'a, T: Array> FusedIterator for Drain<'a, T> {}
382
383
impl<'a, T: 'a + Array> Drop for Drain<'a, T> {
384
0
    fn drop(&mut self) {
385
0
        self.for_each(drop);
386
387
0
        if self.tail_len > 0 {
388
            unsafe {
389
0
                let source_vec = self.vec.as_mut();
390
391
                // memmove back untouched tail, update to new length
392
0
                let start = source_vec.len();
393
0
                let tail = self.tail_start;
394
0
                if tail != start {
395
0
                    // as_mut_ptr creates a &mut, invalidating other pointers.
396
0
                    // This pattern avoids calling it with a pointer already present.
397
0
                    let ptr = source_vec.as_mut_ptr();
398
0
                    let src = ptr.add(tail);
399
0
                    let dst = ptr.add(start);
400
0
                    ptr::copy(src, dst, self.tail_len);
401
0
                }
402
0
                source_vec.set_len(start + self.tail_len);
403
            }
404
0
        }
405
0
    }
406
}
407
408
#[cfg(feature = "union")]
409
union SmallVecData<A: Array> {
410
    inline: core::mem::ManuallyDrop<MaybeUninit<A>>,
411
    heap: (*mut A::Item, usize),
412
}
413
414
#[cfg(all(feature = "union", feature = "const_new"))]
415
impl<T, const N: usize> SmallVecData<[T; N]> {
416
    #[cfg_attr(docsrs, doc(cfg(feature = "const_new")))]
417
    #[inline]
418
    const fn from_const(inline: MaybeUninit<[T; N]>) -> Self {
419
        SmallVecData {
420
            inline: core::mem::ManuallyDrop::new(inline),
421
        }
422
    }
423
}
424
425
#[cfg(feature = "union")]
426
impl<A: Array> SmallVecData<A> {
427
    #[inline]
428
    unsafe fn inline(&self) -> *const A::Item {
429
        self.inline.as_ptr() as *const A::Item
430
    }
431
    #[inline]
432
    unsafe fn inline_mut(&mut self) -> *mut A::Item {
433
        self.inline.as_mut_ptr() as *mut A::Item
434
    }
435
    #[inline]
436
    fn from_inline(inline: MaybeUninit<A>) -> SmallVecData<A> {
437
        SmallVecData {
438
            inline: core::mem::ManuallyDrop::new(inline),
439
        }
440
    }
441
    #[inline]
442
    unsafe fn into_inline(self) -> MaybeUninit<A> {
443
        core::mem::ManuallyDrop::into_inner(self.inline)
444
    }
445
    #[inline]
446
    unsafe fn heap(&self) -> (*mut A::Item, usize) {
447
        self.heap
448
    }
449
    #[inline]
450
    unsafe fn heap_mut(&mut self) -> &mut (*mut A::Item, usize) {
451
        &mut self.heap
452
    }
453
    #[inline]
454
    fn from_heap(ptr: *mut A::Item, len: usize) -> SmallVecData<A> {
455
        SmallVecData { heap: (ptr, len) }
456
    }
457
}
458
459
#[cfg(not(feature = "union"))]
460
enum SmallVecData<A: Array> {
461
    Inline(MaybeUninit<A>),
462
    Heap((*mut A::Item, usize)),
463
}
464
465
#[cfg(all(not(feature = "union"), feature = "const_new"))]
466
impl<T, const N: usize> SmallVecData<[T; N]> {
467
    #[cfg_attr(docsrs, doc(cfg(feature = "const_new")))]
468
    #[inline]
469
    const fn from_const(inline: MaybeUninit<[T; N]>) -> Self {
470
        SmallVecData::Inline(inline)
471
    }
472
}
473
474
#[cfg(not(feature = "union"))]
475
impl<A: Array> SmallVecData<A> {
476
    #[inline]
477
7.23M
    unsafe fn inline(&self) -> *const A::Item {
478
7.23M
        match self {
479
7.23M
            SmallVecData::Inline(a) => a.as_ptr() as *const A::Item,
480
0
            _ => debug_unreachable!(),
481
        }
482
7.23M
    }
Unexecuted instantiation: <smallvec::SmallVecData<_>>::inline
Unexecuted instantiation: <smallvec::SmallVecData<[base::wait_context::TriggeredEvent<<devices::serial::Serial>::spawn_input_thread::{closure#0}::Token>; 16]>>::inline
Unexecuted instantiation: <smallvec::SmallVecData<[base::wait_context::TriggeredEvent<devices::bat::Token>; 16]>>::inline
Unexecuted instantiation: <smallvec::SmallVecData<[base::wait_context::TriggeredEvent<devices::pit::Token>; 16]>>::inline
Unexecuted instantiation: <smallvec::SmallVecData<[base::wait_context::TriggeredEvent<devices::virtio::console::worker::Token>; 16]>>::inline
Unexecuted instantiation: <smallvec::SmallVecData<[base::wait_context::TriggeredEvent<<devices::vmwdt::Vmwdt>::vmwdt_worker_thread::Token>; 16]>>::inline
Unexecuted instantiation: <smallvec::SmallVecData<[base::wait_context::TriggeredEvent<<devices::virtio::p9::Worker>::run::Token>; 16]>>::inline
Unexecuted instantiation: <smallvec::SmallVecData<[base::wait_context::TriggeredEvent<<devices::virtio::rng::Worker>::run::Token>; 16]>>::inline
Unexecuted instantiation: <smallvec::SmallVecData<[base::wait_context::TriggeredEvent<<devices::virtio::vhost_user_frontend::worker::Worker>::run::Token>; 16]>>::inline
Unexecuted instantiation: <smallvec::SmallVecData<[base::wait_context::TriggeredEvent<<devices::virtio::vhost::worker::Worker<_>>::run::Token>; 16]>>::inline
Unexecuted instantiation: <smallvec::SmallVecData<[base::wait_context::TriggeredEvent<<devices::pci::coiommu::PinWorker>::run::Token>; 16]>>::inline
Unexecuted instantiation: <smallvec::SmallVecData<[base::wait_context::TriggeredEvent<<devices::pci::coiommu::UnpinWorker>::run::Token>; 16]>>::inline
Unexecuted instantiation: <smallvec::SmallVecData<[base::wait_context::TriggeredEvent<<devices::pci::vfio_pci::VfioPciWorker>::run::Token>; 16]>>::inline
Unexecuted instantiation: <smallvec::SmallVecData<[base::wait_context::TriggeredEvent<<devices::virtio::fs::worker::Worker<_>>::run::Token>; 16]>>::inline
Unexecuted instantiation: <smallvec::SmallVecData<[base::wait_context::TriggeredEvent<<devices::virtio::wl::Worker>::run::Token>; 16]>>::inline
Unexecuted instantiation: <smallvec::SmallVecData<[base::wait_context::TriggeredEvent<devices::virtcpufreq_v2::vcpufreq_worker_thread::Token>; 16]>>::inline
Unexecuted instantiation: <smallvec::SmallVecData<[base::wait_context::TriggeredEvent<devices::acpi::run_worker::Token>; 16]>>::inline
Unexecuted instantiation: <smallvec::SmallVecData<[base::wait_context::TriggeredEvent<devices::cmos::run_cmos_worker::Token>; 16]>>::inline
Unexecuted instantiation: <smallvec::SmallVecData<[base::wait_context::TriggeredEvent<devices::virtio::interrupt::interrupt_resample_thread::Token>; 16]>>::inline
Unexecuted instantiation: <smallvec::SmallVecData<[base::wait_context::TriggeredEvent<devices::virtio::console::sys::linux::read_input::Token>; 16]>>::inline
Unexecuted instantiation: <smallvec::SmallVecData<[base::wait_context::TriggeredEvent<u32>; 16]>>::inline
<smallvec::SmallVecData<[base::volatile_memory::VolatileSlice; 16]>>::inline
Line
Count
Source
477
1.84M
    unsafe fn inline(&self) -> *const A::Item {
478
1.84M
        match self {
479
1.84M
            SmallVecData::Inline(a) => a.as_ptr() as *const A::Item,
480
0
            _ => debug_unreachable!(),
481
        }
482
1.84M
    }
<smallvec::SmallVecData<[cros_async::mem::MemRegion; 2]>>::inline
Line
Count
Source
477
5.38M
    unsafe fn inline(&self) -> *const A::Item {
478
5.38M
        match self {
479
5.38M
            SmallVecData::Inline(a) => a.as_ptr() as *const A::Item,
480
0
            _ => debug_unreachable!(),
481
        }
482
5.38M
    }
Unexecuted instantiation: <smallvec::SmallVecData<[base::wait_context::TriggeredEvent<metrics::controller::MetricsControllerToken>; 16]>>::inline
Unexecuted instantiation: <smallvec::SmallVecData<[base::wait_context::TriggeredEvent<usize>; 16]>>::inline
483
    #[inline]
484
7.19M
    unsafe fn inline_mut(&mut self) -> *mut A::Item {
485
7.19M
        match self {
486
7.19M
            SmallVecData::Inline(a) => a.as_mut_ptr() as *mut A::Item,
487
0
            _ => debug_unreachable!(),
488
        }
489
7.19M
    }
Unexecuted instantiation: <smallvec::SmallVecData<_>>::inline_mut
Unexecuted instantiation: <smallvec::SmallVecData<[base::wait_context::TriggeredEvent<<devices::serial::Serial>::spawn_input_thread::{closure#0}::Token>; 16]>>::inline_mut
Unexecuted instantiation: <smallvec::SmallVecData<[base::wait_context::TriggeredEvent<devices::bat::Token>; 16]>>::inline_mut
Unexecuted instantiation: <smallvec::SmallVecData<[base::wait_context::TriggeredEvent<devices::pit::Token>; 16]>>::inline_mut
Unexecuted instantiation: <smallvec::SmallVecData<[base::wait_context::TriggeredEvent<devices::virtio::console::worker::Token>; 16]>>::inline_mut
Unexecuted instantiation: <smallvec::SmallVecData<[base::wait_context::TriggeredEvent<<devices::vmwdt::Vmwdt>::vmwdt_worker_thread::Token>; 16]>>::inline_mut
Unexecuted instantiation: <smallvec::SmallVecData<[base::wait_context::TriggeredEvent<<devices::virtio::p9::Worker>::run::Token>; 16]>>::inline_mut
Unexecuted instantiation: <smallvec::SmallVecData<[base::wait_context::TriggeredEvent<<devices::virtio::rng::Worker>::run::Token>; 16]>>::inline_mut
Unexecuted instantiation: <smallvec::SmallVecData<[base::wait_context::TriggeredEvent<<devices::virtio::vhost_user_frontend::worker::Worker>::run::Token>; 16]>>::inline_mut
Unexecuted instantiation: <smallvec::SmallVecData<[base::wait_context::TriggeredEvent<<devices::virtio::vhost::worker::Worker<_>>::run::Token>; 16]>>::inline_mut
Unexecuted instantiation: <smallvec::SmallVecData<[base::wait_context::TriggeredEvent<<devices::pci::coiommu::PinWorker>::run::Token>; 16]>>::inline_mut
Unexecuted instantiation: <smallvec::SmallVecData<[base::wait_context::TriggeredEvent<<devices::pci::coiommu::UnpinWorker>::run::Token>; 16]>>::inline_mut
Unexecuted instantiation: <smallvec::SmallVecData<[base::wait_context::TriggeredEvent<<devices::pci::vfio_pci::VfioPciWorker>::run::Token>; 16]>>::inline_mut
Unexecuted instantiation: <smallvec::SmallVecData<[base::wait_context::TriggeredEvent<<devices::virtio::fs::worker::Worker<_>>::run::Token>; 16]>>::inline_mut
Unexecuted instantiation: <smallvec::SmallVecData<[base::wait_context::TriggeredEvent<<devices::virtio::wl::Worker>::run::Token>; 16]>>::inline_mut
Unexecuted instantiation: <smallvec::SmallVecData<[base::wait_context::TriggeredEvent<devices::virtcpufreq_v2::vcpufreq_worker_thread::Token>; 16]>>::inline_mut
Unexecuted instantiation: <smallvec::SmallVecData<[base::wait_context::TriggeredEvent<devices::acpi::run_worker::Token>; 16]>>::inline_mut
Unexecuted instantiation: <smallvec::SmallVecData<[base::wait_context::TriggeredEvent<devices::cmos::run_cmos_worker::Token>; 16]>>::inline_mut
Unexecuted instantiation: <smallvec::SmallVecData<[base::wait_context::TriggeredEvent<devices::virtio::interrupt::interrupt_resample_thread::Token>; 16]>>::inline_mut
Unexecuted instantiation: <smallvec::SmallVecData<[base::wait_context::TriggeredEvent<devices::virtio::console::sys::linux::read_input::Token>; 16]>>::inline_mut
Unexecuted instantiation: <smallvec::SmallVecData<[base::wait_context::TriggeredEvent<u32>; 16]>>::inline_mut
<smallvec::SmallVecData<[base::volatile_memory::VolatileSlice; 16]>>::inline_mut
Line
Count
Source
484
2.61M
    unsafe fn inline_mut(&mut self) -> *mut A::Item {
485
2.61M
        match self {
486
2.61M
            SmallVecData::Inline(a) => a.as_mut_ptr() as *mut A::Item,
487
0
            _ => debug_unreachable!(),
488
        }
489
2.61M
    }
<smallvec::SmallVecData<[cros_async::mem::MemRegion; 2]>>::inline_mut
Line
Count
Source
484
4.57M
    unsafe fn inline_mut(&mut self) -> *mut A::Item {
485
4.57M
        match self {
486
4.57M
            SmallVecData::Inline(a) => a.as_mut_ptr() as *mut A::Item,
487
0
            _ => debug_unreachable!(),
488
        }
489
4.57M
    }
Unexecuted instantiation: <smallvec::SmallVecData<[base::wait_context::TriggeredEvent<metrics::controller::MetricsControllerToken>; 16]>>::inline_mut
Unexecuted instantiation: <smallvec::SmallVecData<[base::wait_context::TriggeredEvent<usize>; 16]>>::inline_mut
490
    #[inline]
491
2.43M
    fn from_inline(inline: MaybeUninit<A>) -> SmallVecData<A> {
492
2.43M
        SmallVecData::Inline(inline)
493
2.43M
    }
Unexecuted instantiation: <smallvec::SmallVecData<_>>::from_inline
Unexecuted instantiation: <smallvec::SmallVecData<[base::wait_context::TriggeredEvent<<devices::serial::Serial>::spawn_input_thread::{closure#0}::Token>; 16]>>::from_inline
Unexecuted instantiation: <smallvec::SmallVecData<[base::wait_context::TriggeredEvent<devices::bat::Token>; 16]>>::from_inline
Unexecuted instantiation: <smallvec::SmallVecData<[base::wait_context::TriggeredEvent<devices::pit::Token>; 16]>>::from_inline
Unexecuted instantiation: <smallvec::SmallVecData<[base::wait_context::TriggeredEvent<devices::virtio::console::worker::Token>; 16]>>::from_inline
Unexecuted instantiation: <smallvec::SmallVecData<[base::wait_context::TriggeredEvent<<devices::vmwdt::Vmwdt>::vmwdt_worker_thread::Token>; 16]>>::from_inline
Unexecuted instantiation: <smallvec::SmallVecData<[base::wait_context::TriggeredEvent<<devices::virtio::p9::Worker>::run::Token>; 16]>>::from_inline
Unexecuted instantiation: <smallvec::SmallVecData<[base::wait_context::TriggeredEvent<<devices::virtio::rng::Worker>::run::Token>; 16]>>::from_inline
Unexecuted instantiation: <smallvec::SmallVecData<[base::wait_context::TriggeredEvent<<devices::virtio::vhost_user_frontend::worker::Worker>::run::Token>; 16]>>::from_inline
Unexecuted instantiation: <smallvec::SmallVecData<[base::wait_context::TriggeredEvent<<devices::virtio::vhost::worker::Worker<_>>::run::Token>; 16]>>::from_inline
Unexecuted instantiation: <smallvec::SmallVecData<[base::wait_context::TriggeredEvent<<devices::pci::coiommu::PinWorker>::run::Token>; 16]>>::from_inline
Unexecuted instantiation: <smallvec::SmallVecData<[base::wait_context::TriggeredEvent<<devices::pci::coiommu::UnpinWorker>::run::Token>; 16]>>::from_inline
Unexecuted instantiation: <smallvec::SmallVecData<[base::wait_context::TriggeredEvent<<devices::pci::vfio_pci::VfioPciWorker>::run::Token>; 16]>>::from_inline
Unexecuted instantiation: <smallvec::SmallVecData<[base::wait_context::TriggeredEvent<<devices::virtio::fs::worker::Worker<_>>::run::Token>; 16]>>::from_inline
Unexecuted instantiation: <smallvec::SmallVecData<[base::wait_context::TriggeredEvent<<devices::virtio::wl::Worker>::run::Token>; 16]>>::from_inline
Unexecuted instantiation: <smallvec::SmallVecData<[base::wait_context::TriggeredEvent<devices::virtcpufreq_v2::vcpufreq_worker_thread::Token>; 16]>>::from_inline
Unexecuted instantiation: <smallvec::SmallVecData<[base::wait_context::TriggeredEvent<devices::acpi::run_worker::Token>; 16]>>::from_inline
Unexecuted instantiation: <smallvec::SmallVecData<[base::wait_context::TriggeredEvent<devices::cmos::run_cmos_worker::Token>; 16]>>::from_inline
Unexecuted instantiation: <smallvec::SmallVecData<[base::wait_context::TriggeredEvent<devices::virtio::interrupt::interrupt_resample_thread::Token>; 16]>>::from_inline
Unexecuted instantiation: <smallvec::SmallVecData<[base::wait_context::TriggeredEvent<devices::virtio::console::sys::linux::read_input::Token>; 16]>>::from_inline
Unexecuted instantiation: <smallvec::SmallVecData<[base::wait_context::TriggeredEvent<u32>; 16]>>::from_inline
<smallvec::SmallVecData<[base::volatile_memory::VolatileSlice; 16]>>::from_inline
Line
Count
Source
491
654k
    fn from_inline(inline: MaybeUninit<A>) -> SmallVecData<A> {
492
654k
        SmallVecData::Inline(inline)
493
654k
    }
<smallvec::SmallVecData<[cros_async::mem::MemRegion; 2]>>::from_inline
Line
Count
Source
491
1.78M
    fn from_inline(inline: MaybeUninit<A>) -> SmallVecData<A> {
492
1.78M
        SmallVecData::Inline(inline)
493
1.78M
    }
Unexecuted instantiation: <smallvec::SmallVecData<[devices::virtio::iommu::memory_mapper::MemRegion; 1]>>::from_inline
Unexecuted instantiation: <smallvec::SmallVecData<[base::wait_context::TriggeredEvent<metrics::controller::MetricsControllerToken>; 16]>>::from_inline
Unexecuted instantiation: <smallvec::SmallVecData<[base::wait_context::TriggeredEvent<usize>; 16]>>::from_inline
494
    #[inline]
495
0
    unsafe fn into_inline(self) -> MaybeUninit<A> {
496
0
        match self {
497
0
            SmallVecData::Inline(a) => a,
498
0
            _ => debug_unreachable!(),
499
        }
500
0
    }
501
    #[inline]
502
1.91M
    unsafe fn heap(&self) -> (*mut A::Item, usize) {
503
1.91M
        match self {
504
1.91M
            SmallVecData::Heap(data) => *data,
505
0
            _ => debug_unreachable!(),
506
        }
507
1.91M
    }
Unexecuted instantiation: <smallvec::SmallVecData<_>>::heap
Unexecuted instantiation: <smallvec::SmallVecData<[base::wait_context::TriggeredEvent<<devices::serial::Serial>::spawn_input_thread::{closure#0}::Token>; 16]>>::heap
Unexecuted instantiation: <smallvec::SmallVecData<[base::wait_context::TriggeredEvent<devices::bat::Token>; 16]>>::heap
Unexecuted instantiation: <smallvec::SmallVecData<[base::wait_context::TriggeredEvent<devices::pit::Token>; 16]>>::heap
Unexecuted instantiation: <smallvec::SmallVecData<[base::wait_context::TriggeredEvent<devices::virtio::console::worker::Token>; 16]>>::heap
Unexecuted instantiation: <smallvec::SmallVecData<[base::wait_context::TriggeredEvent<<devices::vmwdt::Vmwdt>::vmwdt_worker_thread::Token>; 16]>>::heap
Unexecuted instantiation: <smallvec::SmallVecData<[base::wait_context::TriggeredEvent<<devices::virtio::p9::Worker>::run::Token>; 16]>>::heap
Unexecuted instantiation: <smallvec::SmallVecData<[base::wait_context::TriggeredEvent<<devices::virtio::rng::Worker>::run::Token>; 16]>>::heap
Unexecuted instantiation: <smallvec::SmallVecData<[base::wait_context::TriggeredEvent<<devices::virtio::vhost_user_frontend::worker::Worker>::run::Token>; 16]>>::heap
Unexecuted instantiation: <smallvec::SmallVecData<[base::wait_context::TriggeredEvent<<devices::virtio::vhost::worker::Worker<_>>::run::Token>; 16]>>::heap
Unexecuted instantiation: <smallvec::SmallVecData<[base::wait_context::TriggeredEvent<<devices::pci::coiommu::PinWorker>::run::Token>; 16]>>::heap
Unexecuted instantiation: <smallvec::SmallVecData<[base::wait_context::TriggeredEvent<<devices::pci::coiommu::UnpinWorker>::run::Token>; 16]>>::heap
Unexecuted instantiation: <smallvec::SmallVecData<[base::wait_context::TriggeredEvent<<devices::pci::vfio_pci::VfioPciWorker>::run::Token>; 16]>>::heap
Unexecuted instantiation: <smallvec::SmallVecData<[base::wait_context::TriggeredEvent<<devices::virtio::fs::worker::Worker<_>>::run::Token>; 16]>>::heap
Unexecuted instantiation: <smallvec::SmallVecData<[base::wait_context::TriggeredEvent<<devices::virtio::wl::Worker>::run::Token>; 16]>>::heap
Unexecuted instantiation: <smallvec::SmallVecData<[base::wait_context::TriggeredEvent<devices::virtcpufreq_v2::vcpufreq_worker_thread::Token>; 16]>>::heap
Unexecuted instantiation: <smallvec::SmallVecData<[base::wait_context::TriggeredEvent<devices::acpi::run_worker::Token>; 16]>>::heap
Unexecuted instantiation: <smallvec::SmallVecData<[base::wait_context::TriggeredEvent<devices::cmos::run_cmos_worker::Token>; 16]>>::heap
Unexecuted instantiation: <smallvec::SmallVecData<[base::wait_context::TriggeredEvent<devices::virtio::interrupt::interrupt_resample_thread::Token>; 16]>>::heap
Unexecuted instantiation: <smallvec::SmallVecData<[base::wait_context::TriggeredEvent<devices::virtio::console::sys::linux::read_input::Token>; 16]>>::heap
Unexecuted instantiation: <smallvec::SmallVecData<[base::wait_context::TriggeredEvent<u32>; 16]>>::heap
Unexecuted instantiation: <smallvec::SmallVecData<[base::volatile_memory::VolatileSlice; 16]>>::heap
<smallvec::SmallVecData<[cros_async::mem::MemRegion; 2]>>::heap
Line
Count
Source
502
1.91M
    unsafe fn heap(&self) -> (*mut A::Item, usize) {
503
1.91M
        match self {
504
1.91M
            SmallVecData::Heap(data) => *data,
505
0
            _ => debug_unreachable!(),
506
        }
507
1.91M
    }
Unexecuted instantiation: <smallvec::SmallVecData<[base::wait_context::TriggeredEvent<metrics::controller::MetricsControllerToken>; 16]>>::heap
Unexecuted instantiation: <smallvec::SmallVecData<[base::wait_context::TriggeredEvent<usize>; 16]>>::heap
508
    #[inline]
509
309k
    unsafe fn heap_mut(&mut self) -> &mut (*mut A::Item, usize) {
510
309k
        match self {
511
309k
            SmallVecData::Heap(data) => data,
512
0
            _ => debug_unreachable!(),
513
        }
514
309k
    }
Unexecuted instantiation: <smallvec::SmallVecData<_>>::heap_mut
Unexecuted instantiation: <smallvec::SmallVecData<[base::wait_context::TriggeredEvent<<devices::serial::Serial>::spawn_input_thread::{closure#0}::Token>; 16]>>::heap_mut
Unexecuted instantiation: <smallvec::SmallVecData<[base::wait_context::TriggeredEvent<devices::bat::Token>; 16]>>::heap_mut
Unexecuted instantiation: <smallvec::SmallVecData<[base::wait_context::TriggeredEvent<devices::pit::Token>; 16]>>::heap_mut
Unexecuted instantiation: <smallvec::SmallVecData<[base::wait_context::TriggeredEvent<devices::virtio::console::worker::Token>; 16]>>::heap_mut
Unexecuted instantiation: <smallvec::SmallVecData<[base::wait_context::TriggeredEvent<<devices::vmwdt::Vmwdt>::vmwdt_worker_thread::Token>; 16]>>::heap_mut
Unexecuted instantiation: <smallvec::SmallVecData<[base::wait_context::TriggeredEvent<<devices::virtio::p9::Worker>::run::Token>; 16]>>::heap_mut
Unexecuted instantiation: <smallvec::SmallVecData<[base::wait_context::TriggeredEvent<<devices::virtio::rng::Worker>::run::Token>; 16]>>::heap_mut
Unexecuted instantiation: <smallvec::SmallVecData<[base::wait_context::TriggeredEvent<<devices::virtio::vhost_user_frontend::worker::Worker>::run::Token>; 16]>>::heap_mut
Unexecuted instantiation: <smallvec::SmallVecData<[base::wait_context::TriggeredEvent<<devices::virtio::vhost::worker::Worker<_>>::run::Token>; 16]>>::heap_mut
Unexecuted instantiation: <smallvec::SmallVecData<[base::wait_context::TriggeredEvent<<devices::pci::coiommu::PinWorker>::run::Token>; 16]>>::heap_mut
Unexecuted instantiation: <smallvec::SmallVecData<[base::wait_context::TriggeredEvent<<devices::pci::coiommu::UnpinWorker>::run::Token>; 16]>>::heap_mut
Unexecuted instantiation: <smallvec::SmallVecData<[base::wait_context::TriggeredEvent<<devices::pci::vfio_pci::VfioPciWorker>::run::Token>; 16]>>::heap_mut
Unexecuted instantiation: <smallvec::SmallVecData<[base::wait_context::TriggeredEvent<<devices::virtio::fs::worker::Worker<_>>::run::Token>; 16]>>::heap_mut
Unexecuted instantiation: <smallvec::SmallVecData<[base::wait_context::TriggeredEvent<<devices::virtio::wl::Worker>::run::Token>; 16]>>::heap_mut
Unexecuted instantiation: <smallvec::SmallVecData<[base::wait_context::TriggeredEvent<devices::virtcpufreq_v2::vcpufreq_worker_thread::Token>; 16]>>::heap_mut
Unexecuted instantiation: <smallvec::SmallVecData<[base::wait_context::TriggeredEvent<devices::acpi::run_worker::Token>; 16]>>::heap_mut
Unexecuted instantiation: <smallvec::SmallVecData<[base::wait_context::TriggeredEvent<devices::cmos::run_cmos_worker::Token>; 16]>>::heap_mut
Unexecuted instantiation: <smallvec::SmallVecData<[base::wait_context::TriggeredEvent<devices::virtio::interrupt::interrupt_resample_thread::Token>; 16]>>::heap_mut
Unexecuted instantiation: <smallvec::SmallVecData<[base::wait_context::TriggeredEvent<devices::virtio::console::sys::linux::read_input::Token>; 16]>>::heap_mut
Unexecuted instantiation: <smallvec::SmallVecData<[base::wait_context::TriggeredEvent<u32>; 16]>>::heap_mut
Unexecuted instantiation: <smallvec::SmallVecData<[base::volatile_memory::VolatileSlice; 16]>>::heap_mut
<smallvec::SmallVecData<[cros_async::mem::MemRegion; 2]>>::heap_mut
Line
Count
Source
509
309k
    unsafe fn heap_mut(&mut self) -> &mut (*mut A::Item, usize) {
510
309k
        match self {
511
309k
            SmallVecData::Heap(data) => data,
512
0
            _ => debug_unreachable!(),
513
        }
514
309k
    }
Unexecuted instantiation: <smallvec::SmallVecData<[base::wait_context::TriggeredEvent<metrics::controller::MetricsControllerToken>; 16]>>::heap_mut
Unexecuted instantiation: <smallvec::SmallVecData<[base::wait_context::TriggeredEvent<usize>; 16]>>::heap_mut
515
    #[inline]
516
235k
    fn from_heap(ptr: *mut A::Item, len: usize) -> SmallVecData<A> {
517
235k
        SmallVecData::Heap((ptr, len))
518
235k
    }
Unexecuted instantiation: <smallvec::SmallVecData<_>>::from_heap
Unexecuted instantiation: <smallvec::SmallVecData<[base::wait_context::TriggeredEvent<<devices::serial::Serial>::spawn_input_thread::{closure#0}::Token>; 16]>>::from_heap
Unexecuted instantiation: <smallvec::SmallVecData<[base::wait_context::TriggeredEvent<devices::bat::Token>; 16]>>::from_heap
Unexecuted instantiation: <smallvec::SmallVecData<[base::wait_context::TriggeredEvent<devices::pit::Token>; 16]>>::from_heap
Unexecuted instantiation: <smallvec::SmallVecData<[base::wait_context::TriggeredEvent<devices::virtio::console::worker::Token>; 16]>>::from_heap
Unexecuted instantiation: <smallvec::SmallVecData<[base::wait_context::TriggeredEvent<<devices::vmwdt::Vmwdt>::vmwdt_worker_thread::Token>; 16]>>::from_heap
Unexecuted instantiation: <smallvec::SmallVecData<[base::wait_context::TriggeredEvent<<devices::virtio::p9::Worker>::run::Token>; 16]>>::from_heap
Unexecuted instantiation: <smallvec::SmallVecData<[base::wait_context::TriggeredEvent<<devices::virtio::rng::Worker>::run::Token>; 16]>>::from_heap
Unexecuted instantiation: <smallvec::SmallVecData<[base::wait_context::TriggeredEvent<<devices::virtio::vhost_user_frontend::worker::Worker>::run::Token>; 16]>>::from_heap
Unexecuted instantiation: <smallvec::SmallVecData<[base::wait_context::TriggeredEvent<<devices::virtio::vhost::worker::Worker<_>>::run::Token>; 16]>>::from_heap
Unexecuted instantiation: <smallvec::SmallVecData<[base::wait_context::TriggeredEvent<<devices::pci::coiommu::PinWorker>::run::Token>; 16]>>::from_heap
Unexecuted instantiation: <smallvec::SmallVecData<[base::wait_context::TriggeredEvent<<devices::pci::coiommu::UnpinWorker>::run::Token>; 16]>>::from_heap
Unexecuted instantiation: <smallvec::SmallVecData<[base::wait_context::TriggeredEvent<<devices::pci::vfio_pci::VfioPciWorker>::run::Token>; 16]>>::from_heap
Unexecuted instantiation: <smallvec::SmallVecData<[base::wait_context::TriggeredEvent<<devices::virtio::fs::worker::Worker<_>>::run::Token>; 16]>>::from_heap
Unexecuted instantiation: <smallvec::SmallVecData<[base::wait_context::TriggeredEvent<<devices::virtio::wl::Worker>::run::Token>; 16]>>::from_heap
Unexecuted instantiation: <smallvec::SmallVecData<[base::wait_context::TriggeredEvent<devices::virtcpufreq_v2::vcpufreq_worker_thread::Token>; 16]>>::from_heap
Unexecuted instantiation: <smallvec::SmallVecData<[base::wait_context::TriggeredEvent<devices::acpi::run_worker::Token>; 16]>>::from_heap
Unexecuted instantiation: <smallvec::SmallVecData<[base::wait_context::TriggeredEvent<devices::cmos::run_cmos_worker::Token>; 16]>>::from_heap
Unexecuted instantiation: <smallvec::SmallVecData<[base::wait_context::TriggeredEvent<devices::virtio::interrupt::interrupt_resample_thread::Token>; 16]>>::from_heap
Unexecuted instantiation: <smallvec::SmallVecData<[base::wait_context::TriggeredEvent<devices::virtio::console::sys::linux::read_input::Token>; 16]>>::from_heap
Unexecuted instantiation: <smallvec::SmallVecData<[base::wait_context::TriggeredEvent<u32>; 16]>>::from_heap
Unexecuted instantiation: <smallvec::SmallVecData<[base::volatile_memory::VolatileSlice; 16]>>::from_heap
<smallvec::SmallVecData<[cros_async::mem::MemRegion; 2]>>::from_heap
Line
Count
Source
516
235k
    fn from_heap(ptr: *mut A::Item, len: usize) -> SmallVecData<A> {
517
235k
        SmallVecData::Heap((ptr, len))
518
235k
    }
Unexecuted instantiation: <smallvec::SmallVecData<[devices::virtio::iommu::memory_mapper::MemRegion; 1]>>::from_heap
Unexecuted instantiation: <smallvec::SmallVecData<[base::wait_context::TriggeredEvent<metrics::controller::MetricsControllerToken>; 16]>>::from_heap
Unexecuted instantiation: <smallvec::SmallVecData<[base::wait_context::TriggeredEvent<usize>; 16]>>::from_heap
519
}
520
521
unsafe impl<A: Array + Send> Send for SmallVecData<A> {}
522
unsafe impl<A: Array + Sync> Sync for SmallVecData<A> {}
523
524
/// A `Vec`-like container that can store a small number of elements inline.
525
///
526
/// `SmallVec` acts like a vector, but can store a limited amount of data inline within the
527
/// `SmallVec` struct rather than in a separate allocation.  If the data exceeds this limit, the
528
/// `SmallVec` will "spill" its data onto the heap, allocating a new buffer to hold it.
529
///
530
/// The amount of data that a `SmallVec` can store inline depends on its backing store. The backing
531
/// store can be any type that implements the `Array` trait; usually it is a small fixed-sized
532
/// array.  For example a `SmallVec<[u64; 8]>` can hold up to eight 64-bit integers inline.
533
///
534
/// ## Example
535
///
536
/// ```rust
537
/// use smallvec::SmallVec;
538
/// let mut v = SmallVec::<[u8; 4]>::new(); // initialize an empty vector
539
///
540
/// // The vector can hold up to 4 items without spilling onto the heap.
541
/// v.extend(0..4);
542
/// assert_eq!(v.len(), 4);
543
/// assert!(!v.spilled());
544
///
545
/// // Pushing another element will force the buffer to spill:
546
/// v.push(4);
547
/// assert_eq!(v.len(), 5);
548
/// assert!(v.spilled());
549
/// ```
550
pub struct SmallVec<A: Array> {
551
    // The capacity field is used to determine which of the storage variants is active:
552
    // If capacity <= Self::inline_capacity() then the inline variant is used and capacity holds the current length of the vector (number of elements actually in use).
553
    // If capacity > Self::inline_capacity() then the heap variant is used and capacity holds the size of the memory allocation.
554
    capacity: usize,
555
    data: SmallVecData<A>,
556
}
557
558
impl<A: Array> SmallVec<A> {
559
    /// Construct an empty vector
560
    #[inline]
561
2.43M
    pub fn new() -> SmallVec<A> {
562
        // Try to detect invalid custom implementations of `Array`. Hopefully,
563
        // this check should be optimized away entirely for valid ones.
564
2.43M
        assert!(
565
2.43M
            mem::size_of::<A>() == A::size() * mem::size_of::<A::Item>()
566
2.43M
                && mem::align_of::<A>() >= mem::align_of::<A::Item>()
567
        );
568
2.43M
        SmallVec {
569
2.43M
            capacity: 0,
570
2.43M
            data: SmallVecData::from_inline(MaybeUninit::uninit()),
571
2.43M
        }
572
2.43M
    }
Unexecuted instantiation: <smallvec::SmallVec<_>>::new
Unexecuted instantiation: <smallvec::SmallVec<[base::wait_context::TriggeredEvent<<devices::serial::Serial>::spawn_input_thread::{closure#0}::Token>; 16]>>::new
Unexecuted instantiation: <smallvec::SmallVec<[base::wait_context::TriggeredEvent<devices::bat::Token>; 16]>>::new
Unexecuted instantiation: <smallvec::SmallVec<[base::wait_context::TriggeredEvent<devices::pit::Token>; 16]>>::new
Unexecuted instantiation: <smallvec::SmallVec<[base::wait_context::TriggeredEvent<devices::virtio::console::worker::Token>; 16]>>::new
Unexecuted instantiation: <smallvec::SmallVec<[base::wait_context::TriggeredEvent<<devices::vmwdt::Vmwdt>::vmwdt_worker_thread::Token>; 16]>>::new
Unexecuted instantiation: <smallvec::SmallVec<[base::wait_context::TriggeredEvent<<devices::virtio::p9::Worker>::run::Token>; 16]>>::new
Unexecuted instantiation: <smallvec::SmallVec<[base::wait_context::TriggeredEvent<<devices::virtio::rng::Worker>::run::Token>; 16]>>::new
Unexecuted instantiation: <smallvec::SmallVec<[base::wait_context::TriggeredEvent<<devices::virtio::vhost_user_frontend::worker::Worker>::run::Token>; 16]>>::new
Unexecuted instantiation: <smallvec::SmallVec<[base::wait_context::TriggeredEvent<<devices::virtio::vhost::worker::Worker<_>>::run::Token>; 16]>>::new
Unexecuted instantiation: <smallvec::SmallVec<[base::wait_context::TriggeredEvent<<devices::pci::coiommu::PinWorker>::run::Token>; 16]>>::new
Unexecuted instantiation: <smallvec::SmallVec<[base::wait_context::TriggeredEvent<<devices::pci::coiommu::UnpinWorker>::run::Token>; 16]>>::new
Unexecuted instantiation: <smallvec::SmallVec<[base::wait_context::TriggeredEvent<<devices::pci::vfio_pci::VfioPciWorker>::run::Token>; 16]>>::new
Unexecuted instantiation: <smallvec::SmallVec<[base::wait_context::TriggeredEvent<<devices::virtio::fs::worker::Worker<_>>::run::Token>; 16]>>::new
Unexecuted instantiation: <smallvec::SmallVec<[base::wait_context::TriggeredEvent<<devices::virtio::wl::Worker>::run::Token>; 16]>>::new
Unexecuted instantiation: <smallvec::SmallVec<[base::wait_context::TriggeredEvent<devices::virtcpufreq_v2::vcpufreq_worker_thread::Token>; 16]>>::new
Unexecuted instantiation: <smallvec::SmallVec<[base::wait_context::TriggeredEvent<devices::acpi::run_worker::Token>; 16]>>::new
Unexecuted instantiation: <smallvec::SmallVec<[base::wait_context::TriggeredEvent<devices::cmos::run_cmos_worker::Token>; 16]>>::new
Unexecuted instantiation: <smallvec::SmallVec<[base::wait_context::TriggeredEvent<devices::virtio::interrupt::interrupt_resample_thread::Token>; 16]>>::new
Unexecuted instantiation: <smallvec::SmallVec<[base::wait_context::TriggeredEvent<devices::virtio::console::sys::linux::read_input::Token>; 16]>>::new
Unexecuted instantiation: <smallvec::SmallVec<[base::wait_context::TriggeredEvent<u32>; 16]>>::new
<smallvec::SmallVec<[base::volatile_memory::VolatileSlice; 16]>>::new
Line
Count
Source
561
654k
    pub fn new() -> SmallVec<A> {
562
        // Try to detect invalid custom implementations of `Array`. Hopefully,
563
        // this check should be optimized away entirely for valid ones.
564
654k
        assert!(
565
654k
            mem::size_of::<A>() == A::size() * mem::size_of::<A::Item>()
566
654k
                && mem::align_of::<A>() >= mem::align_of::<A::Item>()
567
        );
568
654k
        SmallVec {
569
654k
            capacity: 0,
570
654k
            data: SmallVecData::from_inline(MaybeUninit::uninit()),
571
654k
        }
572
654k
    }
<smallvec::SmallVec<[cros_async::mem::MemRegion; 2]>>::new
Line
Count
Source
561
1.78M
    pub fn new() -> SmallVec<A> {
562
        // Try to detect invalid custom implementations of `Array`. Hopefully,
563
        // this check should be optimized away entirely for valid ones.
564
1.78M
        assert!(
565
1.78M
            mem::size_of::<A>() == A::size() * mem::size_of::<A::Item>()
566
1.78M
                && mem::align_of::<A>() >= mem::align_of::<A::Item>()
567
        );
568
1.78M
        SmallVec {
569
1.78M
            capacity: 0,
570
1.78M
            data: SmallVecData::from_inline(MaybeUninit::uninit()),
571
1.78M
        }
572
1.78M
    }
Unexecuted instantiation: <smallvec::SmallVec<[base::wait_context::TriggeredEvent<metrics::controller::MetricsControllerToken>; 16]>>::new
Unexecuted instantiation: <smallvec::SmallVec<[base::wait_context::TriggeredEvent<usize>; 16]>>::new
573
574
    /// Construct an empty vector with enough capacity pre-allocated to store at least `n`
575
    /// elements.
576
    ///
577
    /// Will create a heap allocation only if `n` is larger than the inline capacity.
578
    ///
579
    /// ```
580
    /// # use smallvec::SmallVec;
581
    ///
582
    /// let v: SmallVec<[u8; 3]> = SmallVec::with_capacity(100);
583
    ///
584
    /// assert!(v.is_empty());
585
    /// assert!(v.capacity() >= 100);
586
    /// ```
587
    #[inline]
588
0
    pub fn with_capacity(n: usize) -> Self {
589
0
        let mut v = SmallVec::new();
590
0
        v.reserve_exact(n);
591
0
        v
592
0
    }
593
594
    /// Construct a new `SmallVec` from a `Vec<A::Item>`.
595
    ///
596
    /// Elements will be copied to the inline buffer if vec.capacity() <= Self::inline_capacity().
597
    ///
598
    /// ```rust
599
    /// use smallvec::SmallVec;
600
    ///
601
    /// let vec = vec![1, 2, 3, 4, 5];
602
    /// let small_vec: SmallVec<[_; 3]> = SmallVec::from_vec(vec);
603
    ///
604
    /// assert_eq!(&*small_vec, &[1, 2, 3, 4, 5]);
605
    /// ```
606
    #[inline]
607
0
    pub fn from_vec(mut vec: Vec<A::Item>) -> SmallVec<A> {
608
0
        if vec.capacity() <= Self::inline_capacity() {
609
            unsafe {
610
0
                let mut data = SmallVecData::<A>::from_inline(MaybeUninit::uninit());
611
0
                let len = vec.len();
612
0
                vec.set_len(0);
613
0
                ptr::copy_nonoverlapping(vec.as_ptr(), data.inline_mut(), len);
614
615
0
                SmallVec {
616
0
                    capacity: len,
617
0
                    data,
618
0
                }
619
            }
620
        } else {
621
0
            let (ptr, cap, len) = (vec.as_mut_ptr(), vec.capacity(), vec.len());
622
0
            mem::forget(vec);
623
624
0
            SmallVec {
625
0
                capacity: cap,
626
0
                data: SmallVecData::from_heap(ptr, len),
627
0
            }
628
        }
629
0
    }
630
631
    /// Constructs a new `SmallVec` on the stack from an `A` without
632
    /// copying elements.
633
    ///
634
    /// ```rust
635
    /// use smallvec::SmallVec;
636
    ///
637
    /// let buf = [1, 2, 3, 4, 5];
638
    /// let small_vec: SmallVec<_> = SmallVec::from_buf(buf);
639
    ///
640
    /// assert_eq!(&*small_vec, &[1, 2, 3, 4, 5]);
641
    /// ```
642
    #[inline]
643
0
    pub fn from_buf(buf: A) -> SmallVec<A> {
644
0
        SmallVec {
645
0
            capacity: A::size(),
646
0
            data: SmallVecData::from_inline(MaybeUninit::new(buf)),
647
0
        }
648
0
    }
649
650
    /// Constructs a new `SmallVec` on the stack from an `A` without
651
    /// copying elements. Also sets the length, which must be less or
652
    /// equal to the size of `buf`.
653
    ///
654
    /// ```rust
655
    /// use smallvec::SmallVec;
656
    ///
657
    /// let buf = [1, 2, 3, 4, 5, 0, 0, 0];
658
    /// let small_vec: SmallVec<_> = SmallVec::from_buf_and_len(buf, 5);
659
    ///
660
    /// assert_eq!(&*small_vec, &[1, 2, 3, 4, 5]);
661
    /// ```
662
    #[inline]
663
0
    pub fn from_buf_and_len(buf: A, len: usize) -> SmallVec<A> {
664
0
        assert!(len <= A::size());
665
0
        unsafe { SmallVec::from_buf_and_len_unchecked(MaybeUninit::new(buf), len) }
666
0
    }
667
668
    /// Constructs a new `SmallVec` on the stack from an `A` without
669
    /// copying elements. Also sets the length. The user is responsible
670
    /// for ensuring that `len <= A::size()`.
671
    ///
672
    /// ```rust
673
    /// use smallvec::SmallVec;
674
    /// use std::mem::MaybeUninit;
675
    ///
676
    /// let buf = [1, 2, 3, 4, 5, 0, 0, 0];
677
    /// let small_vec: SmallVec<_> = unsafe {
678
    ///     SmallVec::from_buf_and_len_unchecked(MaybeUninit::new(buf), 5)
679
    /// };
680
    ///
681
    /// assert_eq!(&*small_vec, &[1, 2, 3, 4, 5]);
682
    /// ```
683
    #[inline]
684
0
    pub unsafe fn from_buf_and_len_unchecked(buf: MaybeUninit<A>, len: usize) -> SmallVec<A> {
685
0
        SmallVec {
686
0
            capacity: len,
687
0
            data: SmallVecData::from_inline(buf),
688
0
        }
689
0
    }
690
691
    /// Sets the length of a vector.
692
    ///
693
    /// This will explicitly set the size of the vector, without actually
694
    /// modifying its buffers, so it is up to the caller to ensure that the
695
    /// vector is actually the specified size.
696
654k
    pub unsafe fn set_len(&mut self, new_len: usize) {
697
654k
        let (_, len_ptr, _) = self.triple_mut();
698
654k
        *len_ptr = new_len;
699
654k
    }
Unexecuted instantiation: <smallvec::SmallVec<_>>::set_len
Unexecuted instantiation: <smallvec::SmallVec<[base::wait_context::TriggeredEvent<<devices::virtio::vhost_user_frontend::worker::Worker>::run::Token>; 16]>>::set_len
Unexecuted instantiation: <smallvec::SmallVec<[base::wait_context::TriggeredEvent<devices::virtio::interrupt::interrupt_resample_thread::Token>; 16]>>::set_len
<smallvec::SmallVec<[base::volatile_memory::VolatileSlice; 16]>>::set_len
Line
Count
Source
696
654k
    pub unsafe fn set_len(&mut self, new_len: usize) {
697
654k
        let (_, len_ptr, _) = self.triple_mut();
698
654k
        *len_ptr = new_len;
699
654k
    }
700
701
    /// The maximum number of elements this vector can hold inline
702
    #[inline]
703
33.5M
    fn inline_capacity() -> usize {
704
33.5M
        if mem::size_of::<A::Item>() > 0 {
705
33.5M
            A::size()
706
        } else {
707
            // For zero-size items code like `ptr.add(offset)` always returns the same pointer.
708
            // Therefore all items are at the same address,
709
            // and any array size has capacity for infinitely many items.
710
            // The capacity is limited by the bit width of the length field.
711
            //
712
            // `Vec` also does this:
713
            // https://github.com/rust-lang/rust/blob/1.44.0/src/liballoc/raw_vec.rs#L186
714
            //
715
            // In our case, this also ensures that a smallvec of zero-size items never spills,
716
            // and we never try to allocate zero bytes which `std::alloc::alloc` disallows.
717
0
            core::usize::MAX
718
        }
719
33.5M
    }
Unexecuted instantiation: <smallvec::SmallVec<_>>::inline_capacity
Unexecuted instantiation: <smallvec::SmallVec<[base::wait_context::TriggeredEvent<<devices::serial::Serial>::spawn_input_thread::{closure#0}::Token>; 16]>>::inline_capacity
Unexecuted instantiation: <smallvec::SmallVec<[base::wait_context::TriggeredEvent<devices::bat::Token>; 16]>>::inline_capacity
Unexecuted instantiation: <smallvec::SmallVec<[base::wait_context::TriggeredEvent<devices::pit::Token>; 16]>>::inline_capacity
Unexecuted instantiation: <smallvec::SmallVec<[base::wait_context::TriggeredEvent<devices::virtio::console::worker::Token>; 16]>>::inline_capacity
Unexecuted instantiation: <smallvec::SmallVec<[base::wait_context::TriggeredEvent<<devices::vmwdt::Vmwdt>::vmwdt_worker_thread::Token>; 16]>>::inline_capacity
Unexecuted instantiation: <smallvec::SmallVec<[base::wait_context::TriggeredEvent<<devices::virtio::p9::Worker>::run::Token>; 16]>>::inline_capacity
Unexecuted instantiation: <smallvec::SmallVec<[base::wait_context::TriggeredEvent<<devices::virtio::rng::Worker>::run::Token>; 16]>>::inline_capacity
Unexecuted instantiation: <smallvec::SmallVec<[base::wait_context::TriggeredEvent<<devices::virtio::vhost_user_frontend::worker::Worker>::run::Token>; 16]>>::inline_capacity
Unexecuted instantiation: <smallvec::SmallVec<[base::wait_context::TriggeredEvent<<devices::virtio::vhost::worker::Worker<_>>::run::Token>; 16]>>::inline_capacity
Unexecuted instantiation: <smallvec::SmallVec<[base::wait_context::TriggeredEvent<<devices::pci::coiommu::PinWorker>::run::Token>; 16]>>::inline_capacity
Unexecuted instantiation: <smallvec::SmallVec<[base::wait_context::TriggeredEvent<<devices::pci::coiommu::UnpinWorker>::run::Token>; 16]>>::inline_capacity
Unexecuted instantiation: <smallvec::SmallVec<[base::wait_context::TriggeredEvent<<devices::pci::vfio_pci::VfioPciWorker>::run::Token>; 16]>>::inline_capacity
Unexecuted instantiation: <smallvec::SmallVec<[base::wait_context::TriggeredEvent<<devices::virtio::fs::worker::Worker<_>>::run::Token>; 16]>>::inline_capacity
Unexecuted instantiation: <smallvec::SmallVec<[base::wait_context::TriggeredEvent<<devices::virtio::wl::Worker>::run::Token>; 16]>>::inline_capacity
Unexecuted instantiation: <smallvec::SmallVec<[base::wait_context::TriggeredEvent<devices::virtcpufreq_v2::vcpufreq_worker_thread::Token>; 16]>>::inline_capacity
Unexecuted instantiation: <smallvec::SmallVec<[base::wait_context::TriggeredEvent<devices::acpi::run_worker::Token>; 16]>>::inline_capacity
Unexecuted instantiation: <smallvec::SmallVec<[base::wait_context::TriggeredEvent<devices::cmos::run_cmos_worker::Token>; 16]>>::inline_capacity
Unexecuted instantiation: <smallvec::SmallVec<[base::wait_context::TriggeredEvent<devices::virtio::interrupt::interrupt_resample_thread::Token>; 16]>>::inline_capacity
Unexecuted instantiation: <smallvec::SmallVec<[base::wait_context::TriggeredEvent<devices::virtio::console::sys::linux::read_input::Token>; 16]>>::inline_capacity
Unexecuted instantiation: <smallvec::SmallVec<[base::wait_context::TriggeredEvent<u32>; 16]>>::inline_capacity
<smallvec::SmallVec<[base::volatile_memory::VolatileSlice; 16]>>::inline_capacity
Line
Count
Source
703
9.57M
    fn inline_capacity() -> usize {
704
9.57M
        if mem::size_of::<A::Item>() > 0 {
705
9.57M
            A::size()
706
        } else {
707
            // For zero-size items code like `ptr.add(offset)` always returns the same pointer.
708
            // Therefore all items are at the same address,
709
            // and any array size has capacity for infinitely many items.
710
            // The capacity is limited by the bit width of the length field.
711
            //
712
            // `Vec` also does this:
713
            // https://github.com/rust-lang/rust/blob/1.44.0/src/liballoc/raw_vec.rs#L186
714
            //
715
            // In our case, this also ensures that a smallvec of zero-size items never spills,
716
            // and we never try to allocate zero bytes which `std::alloc::alloc` disallows.
717
0
            core::usize::MAX
718
        }
719
9.57M
    }
<smallvec::SmallVec<[cros_async::mem::MemRegion; 2]>>::inline_capacity
Line
Count
Source
703
23.9M
    fn inline_capacity() -> usize {
704
23.9M
        if mem::size_of::<A::Item>() > 0 {
705
23.9M
            A::size()
706
        } else {
707
            // For zero-size items code like `ptr.add(offset)` always returns the same pointer.
708
            // Therefore all items are at the same address,
709
            // and any array size has capacity for infinitely many items.
710
            // The capacity is limited by the bit width of the length field.
711
            //
712
            // `Vec` also does this:
713
            // https://github.com/rust-lang/rust/blob/1.44.0/src/liballoc/raw_vec.rs#L186
714
            //
715
            // In our case, this also ensures that a smallvec of zero-size items never spills,
716
            // and we never try to allocate zero bytes which `std::alloc::alloc` disallows.
717
0
            core::usize::MAX
718
        }
719
23.9M
    }
Unexecuted instantiation: <smallvec::SmallVec<[devices::virtio::iommu::memory_mapper::MemRegion; 1]>>::inline_capacity
Unexecuted instantiation: <smallvec::SmallVec<[base::wait_context::TriggeredEvent<metrics::controller::MetricsControllerToken>; 16]>>::inline_capacity
Unexecuted instantiation: <smallvec::SmallVec<[base::wait_context::TriggeredEvent<usize>; 16]>>::inline_capacity
720
721
    /// The maximum number of elements this vector can hold inline
722
    #[inline]
723
235k
    pub fn inline_size(&self) -> usize {
724
235k
        Self::inline_capacity()
725
235k
    }
Unexecuted instantiation: <smallvec::SmallVec<_>>::inline_size
Unexecuted instantiation: <smallvec::SmallVec<[base::wait_context::TriggeredEvent<<devices::serial::Serial>::spawn_input_thread::{closure#0}::Token>; 16]>>::inline_size
Unexecuted instantiation: <smallvec::SmallVec<[base::wait_context::TriggeredEvent<devices::bat::Token>; 16]>>::inline_size
Unexecuted instantiation: <smallvec::SmallVec<[base::wait_context::TriggeredEvent<devices::pit::Token>; 16]>>::inline_size
Unexecuted instantiation: <smallvec::SmallVec<[base::wait_context::TriggeredEvent<devices::virtio::console::worker::Token>; 16]>>::inline_size
Unexecuted instantiation: <smallvec::SmallVec<[base::wait_context::TriggeredEvent<<devices::vmwdt::Vmwdt>::vmwdt_worker_thread::Token>; 16]>>::inline_size
Unexecuted instantiation: <smallvec::SmallVec<[base::wait_context::TriggeredEvent<<devices::virtio::p9::Worker>::run::Token>; 16]>>::inline_size
Unexecuted instantiation: <smallvec::SmallVec<[base::wait_context::TriggeredEvent<<devices::virtio::rng::Worker>::run::Token>; 16]>>::inline_size
Unexecuted instantiation: <smallvec::SmallVec<[base::wait_context::TriggeredEvent<<devices::virtio::vhost_user_frontend::worker::Worker>::run::Token>; 16]>>::inline_size
Unexecuted instantiation: <smallvec::SmallVec<[base::wait_context::TriggeredEvent<<devices::virtio::vhost::worker::Worker<_>>::run::Token>; 16]>>::inline_size
Unexecuted instantiation: <smallvec::SmallVec<[base::wait_context::TriggeredEvent<<devices::pci::coiommu::PinWorker>::run::Token>; 16]>>::inline_size
Unexecuted instantiation: <smallvec::SmallVec<[base::wait_context::TriggeredEvent<<devices::pci::coiommu::UnpinWorker>::run::Token>; 16]>>::inline_size
Unexecuted instantiation: <smallvec::SmallVec<[base::wait_context::TriggeredEvent<<devices::pci::vfio_pci::VfioPciWorker>::run::Token>; 16]>>::inline_size
Unexecuted instantiation: <smallvec::SmallVec<[base::wait_context::TriggeredEvent<<devices::virtio::fs::worker::Worker<_>>::run::Token>; 16]>>::inline_size
Unexecuted instantiation: <smallvec::SmallVec<[base::wait_context::TriggeredEvent<<devices::virtio::wl::Worker>::run::Token>; 16]>>::inline_size
Unexecuted instantiation: <smallvec::SmallVec<[base::wait_context::TriggeredEvent<devices::virtcpufreq_v2::vcpufreq_worker_thread::Token>; 16]>>::inline_size
Unexecuted instantiation: <smallvec::SmallVec<[base::wait_context::TriggeredEvent<devices::acpi::run_worker::Token>; 16]>>::inline_size
Unexecuted instantiation: <smallvec::SmallVec<[base::wait_context::TriggeredEvent<devices::cmos::run_cmos_worker::Token>; 16]>>::inline_size
Unexecuted instantiation: <smallvec::SmallVec<[base::wait_context::TriggeredEvent<devices::virtio::interrupt::interrupt_resample_thread::Token>; 16]>>::inline_size
Unexecuted instantiation: <smallvec::SmallVec<[base::wait_context::TriggeredEvent<devices::virtio::console::sys::linux::read_input::Token>; 16]>>::inline_size
Unexecuted instantiation: <smallvec::SmallVec<[base::wait_context::TriggeredEvent<u32>; 16]>>::inline_size
Unexecuted instantiation: <smallvec::SmallVec<[base::volatile_memory::VolatileSlice; 16]>>::inline_size
<smallvec::SmallVec<[cros_async::mem::MemRegion; 2]>>::inline_size
Line
Count
Source
723
235k
    pub fn inline_size(&self) -> usize {
724
235k
        Self::inline_capacity()
725
235k
    }
Unexecuted instantiation: <smallvec::SmallVec<[base::wait_context::TriggeredEvent<metrics::controller::MetricsControllerToken>; 16]>>::inline_size
Unexecuted instantiation: <smallvec::SmallVec<[base::wait_context::TriggeredEvent<usize>; 16]>>::inline_size
726
727
    /// The number of elements stored in the vector
728
    #[inline]
729
654k
    pub fn len(&self) -> usize {
730
654k
        self.triple().1
731
654k
    }
Unexecuted instantiation: <smallvec::SmallVec<_>>::len
Unexecuted instantiation: <smallvec::SmallVec<[base::wait_context::TriggeredEvent<<devices::virtio::vhost_user_frontend::worker::Worker>::run::Token>; 16]>>::len
Unexecuted instantiation: <smallvec::SmallVec<[base::wait_context::TriggeredEvent<devices::virtio::interrupt::interrupt_resample_thread::Token>; 16]>>::len
<smallvec::SmallVec<[base::volatile_memory::VolatileSlice; 16]>>::len
Line
Count
Source
729
654k
    pub fn len(&self) -> usize {
730
654k
        self.triple().1
731
654k
    }
Unexecuted instantiation: <smallvec::SmallVec<[cros_async::mem::MemRegion; 2]>>::len
732
733
    /// Returns `true` if the vector is empty
734
    #[inline]
735
0
    pub fn is_empty(&self) -> bool {
736
0
        self.len() == 0
737
0
    }
738
739
    /// The number of items the vector can hold without reallocating
740
    #[inline]
741
0
    pub fn capacity(&self) -> usize {
742
0
        self.triple().2
743
0
    }
744
745
    /// Returns a tuple with (data ptr, len, capacity)
746
    /// Useful to get all SmallVec properties with a single check of the current storage variant.
747
    #[inline]
748
8.91M
    fn triple(&self) -> (*const A::Item, usize, usize) {
749
        unsafe {
750
8.91M
            if self.spilled() {
751
1.67M
                let (ptr, len) = self.data.heap();
752
1.67M
                (ptr, len, self.capacity)
753
            } else {
754
7.23M
                (self.data.inline(), self.capacity, Self::inline_capacity())
755
            }
756
        }
757
8.91M
    }
Unexecuted instantiation: <smallvec::SmallVec<_>>::triple
Unexecuted instantiation: <smallvec::SmallVec<[base::wait_context::TriggeredEvent<<devices::serial::Serial>::spawn_input_thread::{closure#0}::Token>; 16]>>::triple
Unexecuted instantiation: <smallvec::SmallVec<[base::wait_context::TriggeredEvent<devices::bat::Token>; 16]>>::triple
Unexecuted instantiation: <smallvec::SmallVec<[base::wait_context::TriggeredEvent<devices::pit::Token>; 16]>>::triple
Unexecuted instantiation: <smallvec::SmallVec<[base::wait_context::TriggeredEvent<devices::virtio::console::worker::Token>; 16]>>::triple
Unexecuted instantiation: <smallvec::SmallVec<[base::wait_context::TriggeredEvent<<devices::vmwdt::Vmwdt>::vmwdt_worker_thread::Token>; 16]>>::triple
Unexecuted instantiation: <smallvec::SmallVec<[base::wait_context::TriggeredEvent<<devices::virtio::p9::Worker>::run::Token>; 16]>>::triple
Unexecuted instantiation: <smallvec::SmallVec<[base::wait_context::TriggeredEvent<<devices::virtio::rng::Worker>::run::Token>; 16]>>::triple
Unexecuted instantiation: <smallvec::SmallVec<[base::wait_context::TriggeredEvent<<devices::virtio::vhost_user_frontend::worker::Worker>::run::Token>; 16]>>::triple
Unexecuted instantiation: <smallvec::SmallVec<[base::wait_context::TriggeredEvent<<devices::virtio::vhost::worker::Worker<_>>::run::Token>; 16]>>::triple
Unexecuted instantiation: <smallvec::SmallVec<[base::wait_context::TriggeredEvent<<devices::pci::coiommu::PinWorker>::run::Token>; 16]>>::triple
Unexecuted instantiation: <smallvec::SmallVec<[base::wait_context::TriggeredEvent<<devices::pci::coiommu::UnpinWorker>::run::Token>; 16]>>::triple
Unexecuted instantiation: <smallvec::SmallVec<[base::wait_context::TriggeredEvent<<devices::pci::vfio_pci::VfioPciWorker>::run::Token>; 16]>>::triple
Unexecuted instantiation: <smallvec::SmallVec<[base::wait_context::TriggeredEvent<<devices::virtio::fs::worker::Worker<_>>::run::Token>; 16]>>::triple
Unexecuted instantiation: <smallvec::SmallVec<[base::wait_context::TriggeredEvent<<devices::virtio::wl::Worker>::run::Token>; 16]>>::triple
Unexecuted instantiation: <smallvec::SmallVec<[base::wait_context::TriggeredEvent<devices::virtcpufreq_v2::vcpufreq_worker_thread::Token>; 16]>>::triple
Unexecuted instantiation: <smallvec::SmallVec<[base::wait_context::TriggeredEvent<devices::acpi::run_worker::Token>; 16]>>::triple
Unexecuted instantiation: <smallvec::SmallVec<[base::wait_context::TriggeredEvent<devices::cmos::run_cmos_worker::Token>; 16]>>::triple
Unexecuted instantiation: <smallvec::SmallVec<[base::wait_context::TriggeredEvent<devices::virtio::interrupt::interrupt_resample_thread::Token>; 16]>>::triple
Unexecuted instantiation: <smallvec::SmallVec<[base::wait_context::TriggeredEvent<devices::virtio::console::sys::linux::read_input::Token>; 16]>>::triple
Unexecuted instantiation: <smallvec::SmallVec<[base::wait_context::TriggeredEvent<u32>; 16]>>::triple
<smallvec::SmallVec<[base::volatile_memory::VolatileSlice; 16]>>::triple
Line
Count
Source
748
1.84M
    fn triple(&self) -> (*const A::Item, usize, usize) {
749
        unsafe {
750
1.84M
            if self.spilled() {
751
0
                let (ptr, len) = self.data.heap();
752
0
                (ptr, len, self.capacity)
753
            } else {
754
1.84M
                (self.data.inline(), self.capacity, Self::inline_capacity())
755
            }
756
        }
757
1.84M
    }
<smallvec::SmallVec<[cros_async::mem::MemRegion; 2]>>::triple
Line
Count
Source
748
7.06M
    fn triple(&self) -> (*const A::Item, usize, usize) {
749
        unsafe {
750
7.06M
            if self.spilled() {
751
1.67M
                let (ptr, len) = self.data.heap();
752
1.67M
                (ptr, len, self.capacity)
753
            } else {
754
5.38M
                (self.data.inline(), self.capacity, Self::inline_capacity())
755
            }
756
        }
757
7.06M
    }
Unexecuted instantiation: <smallvec::SmallVec<[base::wait_context::TriggeredEvent<metrics::controller::MetricsControllerToken>; 16]>>::triple
Unexecuted instantiation: <smallvec::SmallVec<[base::wait_context::TriggeredEvent<usize>; 16]>>::triple
758
759
    /// Returns a tuple with (data ptr, len ptr, capacity)
760
    #[inline]
761
7.26M
    fn triple_mut(&mut self) -> (*mut A::Item, &mut usize, usize) {
762
        unsafe {
763
7.26M
            if self.spilled() {
764
77.3k
                let &mut (ptr, ref mut len_ptr) = self.data.heap_mut();
765
77.3k
                (ptr, len_ptr, self.capacity)
766
            } else {
767
7.19M
                (
768
7.19M
                    self.data.inline_mut(),
769
7.19M
                    &mut self.capacity,
770
7.19M
                    Self::inline_capacity(),
771
7.19M
                )
772
            }
773
        }
774
7.26M
    }
Unexecuted instantiation: <smallvec::SmallVec<_>>::triple_mut
Unexecuted instantiation: <smallvec::SmallVec<[base::wait_context::TriggeredEvent<<devices::serial::Serial>::spawn_input_thread::{closure#0}::Token>; 16]>>::triple_mut
Unexecuted instantiation: <smallvec::SmallVec<[base::wait_context::TriggeredEvent<devices::bat::Token>; 16]>>::triple_mut
Unexecuted instantiation: <smallvec::SmallVec<[base::wait_context::TriggeredEvent<devices::pit::Token>; 16]>>::triple_mut
Unexecuted instantiation: <smallvec::SmallVec<[base::wait_context::TriggeredEvent<devices::virtio::console::worker::Token>; 16]>>::triple_mut
Unexecuted instantiation: <smallvec::SmallVec<[base::wait_context::TriggeredEvent<<devices::vmwdt::Vmwdt>::vmwdt_worker_thread::Token>; 16]>>::triple_mut
Unexecuted instantiation: <smallvec::SmallVec<[base::wait_context::TriggeredEvent<<devices::virtio::p9::Worker>::run::Token>; 16]>>::triple_mut
Unexecuted instantiation: <smallvec::SmallVec<[base::wait_context::TriggeredEvent<<devices::virtio::rng::Worker>::run::Token>; 16]>>::triple_mut
Unexecuted instantiation: <smallvec::SmallVec<[base::wait_context::TriggeredEvent<<devices::virtio::vhost_user_frontend::worker::Worker>::run::Token>; 16]>>::triple_mut
Unexecuted instantiation: <smallvec::SmallVec<[base::wait_context::TriggeredEvent<<devices::virtio::vhost::worker::Worker<_>>::run::Token>; 16]>>::triple_mut
Unexecuted instantiation: <smallvec::SmallVec<[base::wait_context::TriggeredEvent<<devices::pci::coiommu::PinWorker>::run::Token>; 16]>>::triple_mut
Unexecuted instantiation: <smallvec::SmallVec<[base::wait_context::TriggeredEvent<<devices::pci::coiommu::UnpinWorker>::run::Token>; 16]>>::triple_mut
Unexecuted instantiation: <smallvec::SmallVec<[base::wait_context::TriggeredEvent<<devices::pci::vfio_pci::VfioPciWorker>::run::Token>; 16]>>::triple_mut
Unexecuted instantiation: <smallvec::SmallVec<[base::wait_context::TriggeredEvent<<devices::virtio::fs::worker::Worker<_>>::run::Token>; 16]>>::triple_mut
Unexecuted instantiation: <smallvec::SmallVec<[base::wait_context::TriggeredEvent<<devices::virtio::wl::Worker>::run::Token>; 16]>>::triple_mut
Unexecuted instantiation: <smallvec::SmallVec<[base::wait_context::TriggeredEvent<devices::virtcpufreq_v2::vcpufreq_worker_thread::Token>; 16]>>::triple_mut
Unexecuted instantiation: <smallvec::SmallVec<[base::wait_context::TriggeredEvent<devices::acpi::run_worker::Token>; 16]>>::triple_mut
Unexecuted instantiation: <smallvec::SmallVec<[base::wait_context::TriggeredEvent<devices::cmos::run_cmos_worker::Token>; 16]>>::triple_mut
Unexecuted instantiation: <smallvec::SmallVec<[base::wait_context::TriggeredEvent<devices::virtio::interrupt::interrupt_resample_thread::Token>; 16]>>::triple_mut
Unexecuted instantiation: <smallvec::SmallVec<[base::wait_context::TriggeredEvent<devices::virtio::console::sys::linux::read_input::Token>; 16]>>::triple_mut
Unexecuted instantiation: <smallvec::SmallVec<[base::wait_context::TriggeredEvent<u32>; 16]>>::triple_mut
<smallvec::SmallVec<[base::volatile_memory::VolatileSlice; 16]>>::triple_mut
Line
Count
Source
761
2.61M
    fn triple_mut(&mut self) -> (*mut A::Item, &mut usize, usize) {
762
        unsafe {
763
2.61M
            if self.spilled() {
764
0
                let &mut (ptr, ref mut len_ptr) = self.data.heap_mut();
765
0
                (ptr, len_ptr, self.capacity)
766
            } else {
767
2.61M
                (
768
2.61M
                    self.data.inline_mut(),
769
2.61M
                    &mut self.capacity,
770
2.61M
                    Self::inline_capacity(),
771
2.61M
                )
772
            }
773
        }
774
2.61M
    }
<smallvec::SmallVec<[cros_async::mem::MemRegion; 2]>>::triple_mut
Line
Count
Source
761
4.65M
    fn triple_mut(&mut self) -> (*mut A::Item, &mut usize, usize) {
762
        unsafe {
763
4.65M
            if self.spilled() {
764
77.3k
                let &mut (ptr, ref mut len_ptr) = self.data.heap_mut();
765
77.3k
                (ptr, len_ptr, self.capacity)
766
            } else {
767
4.57M
                (
768
4.57M
                    self.data.inline_mut(),
769
4.57M
                    &mut self.capacity,
770
4.57M
                    Self::inline_capacity(),
771
4.57M
                )
772
            }
773
        }
774
4.65M
    }
Unexecuted instantiation: <smallvec::SmallVec<[base::wait_context::TriggeredEvent<metrics::controller::MetricsControllerToken>; 16]>>::triple_mut
Unexecuted instantiation: <smallvec::SmallVec<[base::wait_context::TriggeredEvent<usize>; 16]>>::triple_mut
775
776
    /// Returns `true` if the data has spilled into a separate heap-allocated buffer.
777
    #[inline]
778
18.8M
    pub fn spilled(&self) -> bool {
779
18.8M
        self.capacity > Self::inline_capacity()
780
18.8M
    }
Unexecuted instantiation: <smallvec::SmallVec<_>>::spilled
Unexecuted instantiation: <smallvec::SmallVec<[base::wait_context::TriggeredEvent<<devices::serial::Serial>::spawn_input_thread::{closure#0}::Token>; 16]>>::spilled
Unexecuted instantiation: <smallvec::SmallVec<[base::wait_context::TriggeredEvent<devices::bat::Token>; 16]>>::spilled
Unexecuted instantiation: <smallvec::SmallVec<[base::wait_context::TriggeredEvent<devices::pit::Token>; 16]>>::spilled
Unexecuted instantiation: <smallvec::SmallVec<[base::wait_context::TriggeredEvent<devices::virtio::console::worker::Token>; 16]>>::spilled
Unexecuted instantiation: <smallvec::SmallVec<[base::wait_context::TriggeredEvent<<devices::vmwdt::Vmwdt>::vmwdt_worker_thread::Token>; 16]>>::spilled
Unexecuted instantiation: <smallvec::SmallVec<[base::wait_context::TriggeredEvent<<devices::virtio::p9::Worker>::run::Token>; 16]>>::spilled
Unexecuted instantiation: <smallvec::SmallVec<[base::wait_context::TriggeredEvent<<devices::virtio::rng::Worker>::run::Token>; 16]>>::spilled
Unexecuted instantiation: <smallvec::SmallVec<[base::wait_context::TriggeredEvent<<devices::virtio::vhost_user_frontend::worker::Worker>::run::Token>; 16]>>::spilled
Unexecuted instantiation: <smallvec::SmallVec<[base::wait_context::TriggeredEvent<<devices::virtio::vhost::worker::Worker<_>>::run::Token>; 16]>>::spilled
Unexecuted instantiation: <smallvec::SmallVec<[base::wait_context::TriggeredEvent<<devices::pci::coiommu::PinWorker>::run::Token>; 16]>>::spilled
Unexecuted instantiation: <smallvec::SmallVec<[base::wait_context::TriggeredEvent<<devices::pci::coiommu::UnpinWorker>::run::Token>; 16]>>::spilled
Unexecuted instantiation: <smallvec::SmallVec<[base::wait_context::TriggeredEvent<<devices::pci::vfio_pci::VfioPciWorker>::run::Token>; 16]>>::spilled
Unexecuted instantiation: <smallvec::SmallVec<[base::wait_context::TriggeredEvent<<devices::virtio::fs::worker::Worker<_>>::run::Token>; 16]>>::spilled
Unexecuted instantiation: <smallvec::SmallVec<[base::wait_context::TriggeredEvent<<devices::virtio::wl::Worker>::run::Token>; 16]>>::spilled
Unexecuted instantiation: <smallvec::SmallVec<[base::wait_context::TriggeredEvent<devices::virtcpufreq_v2::vcpufreq_worker_thread::Token>; 16]>>::spilled
Unexecuted instantiation: <smallvec::SmallVec<[base::wait_context::TriggeredEvent<devices::acpi::run_worker::Token>; 16]>>::spilled
Unexecuted instantiation: <smallvec::SmallVec<[base::wait_context::TriggeredEvent<devices::cmos::run_cmos_worker::Token>; 16]>>::spilled
Unexecuted instantiation: <smallvec::SmallVec<[base::wait_context::TriggeredEvent<devices::virtio::interrupt::interrupt_resample_thread::Token>; 16]>>::spilled
Unexecuted instantiation: <smallvec::SmallVec<[base::wait_context::TriggeredEvent<devices::virtio::console::sys::linux::read_input::Token>; 16]>>::spilled
Unexecuted instantiation: <smallvec::SmallVec<[base::wait_context::TriggeredEvent<u32>; 16]>>::spilled
<smallvec::SmallVec<[base::volatile_memory::VolatileSlice; 16]>>::spilled
Line
Count
Source
778
5.11M
    pub fn spilled(&self) -> bool {
779
5.11M
        self.capacity > Self::inline_capacity()
780
5.11M
    }
<smallvec::SmallVec<[cros_async::mem::MemRegion; 2]>>::spilled
Line
Count
Source
778
13.7M
    pub fn spilled(&self) -> bool {
779
13.7M
        self.capacity > Self::inline_capacity()
780
13.7M
    }
Unexecuted instantiation: <smallvec::SmallVec<[base::wait_context::TriggeredEvent<metrics::controller::MetricsControllerToken>; 16]>>::spilled
Unexecuted instantiation: <smallvec::SmallVec<[base::wait_context::TriggeredEvent<usize>; 16]>>::spilled
781
782
    /// Creates a draining iterator that removes the specified range in the vector
783
    /// and yields the removed items.
784
    ///
785
    /// Note 1: The element range is removed even if the iterator is only
786
    /// partially consumed or not consumed at all.
787
    ///
788
    /// Note 2: It is unspecified how many elements are removed from the vector
789
    /// if the `Drain` value is leaked.
790
    ///
791
    /// # Panics
792
    ///
793
    /// Panics if the starting point is greater than the end point or if
794
    /// the end point is greater than the length of the vector.
795
0
    pub fn drain<R>(&mut self, range: R) -> Drain<'_, A>
796
0
    where
797
0
        R: RangeBounds<usize>,
798
    {
799
        use core::ops::Bound::*;
800
801
0
        let len = self.len();
802
0
        let start = match range.start_bound() {
803
0
            Included(&n) => n,
804
0
            Excluded(&n) => n.checked_add(1).expect("Range start out of bounds"),
805
0
            Unbounded => 0,
806
        };
807
0
        let end = match range.end_bound() {
808
0
            Included(&n) => n.checked_add(1).expect("Range end out of bounds"),
809
0
            Excluded(&n) => n,
810
0
            Unbounded => len,
811
        };
812
813
0
        assert!(start <= end);
814
0
        assert!(end <= len);
815
816
        unsafe {
817
0
            self.set_len(start);
818
819
0
            let range_slice = slice::from_raw_parts(self.as_ptr().add(start), end - start);
820
821
0
            Drain {
822
0
                tail_start: end,
823
0
                tail_len: len - end,
824
0
                iter: range_slice.iter(),
825
0
                // Since self is a &mut, passing it to a function would invalidate the slice iterator.
826
0
                vec: NonNull::new_unchecked(self as *mut _),
827
0
            }
828
        }
829
0
    }
830
831
    /// Append an item to the vector.
832
    #[inline]
833
1.68M
    pub fn push(&mut self, value: A::Item) {
834
        unsafe {
835
1.68M
            let (mut ptr, mut len, cap) = self.triple_mut();
836
1.68M
            if *len == cap {
837
232k
                self.reserve(1);
838
232k
                let &mut (heap_ptr, ref mut heap_len) = self.data.heap_mut();
839
232k
                ptr = heap_ptr;
840
232k
                len = heap_len;
841
1.44M
            }
842
1.68M
            ptr::write(ptr.add(*len), value);
843
1.68M
            *len += 1;
844
        }
845
1.68M
    }
Unexecuted instantiation: <smallvec::SmallVec<_>>::push
Unexecuted instantiation: <smallvec::SmallVec<[base::wait_context::TriggeredEvent<<devices::serial::Serial>::spawn_input_thread::{closure#0}::Token>; 16]>>::push
Unexecuted instantiation: <smallvec::SmallVec<[base::wait_context::TriggeredEvent<devices::bat::Token>; 16]>>::push
Unexecuted instantiation: <smallvec::SmallVec<[base::wait_context::TriggeredEvent<devices::pit::Token>; 16]>>::push
Unexecuted instantiation: <smallvec::SmallVec<[base::wait_context::TriggeredEvent<devices::virtio::console::worker::Token>; 16]>>::push
Unexecuted instantiation: <smallvec::SmallVec<[base::wait_context::TriggeredEvent<<devices::vmwdt::Vmwdt>::vmwdt_worker_thread::Token>; 16]>>::push
Unexecuted instantiation: <smallvec::SmallVec<[base::wait_context::TriggeredEvent<<devices::virtio::p9::Worker>::run::Token>; 16]>>::push
Unexecuted instantiation: <smallvec::SmallVec<[base::wait_context::TriggeredEvent<<devices::virtio::rng::Worker>::run::Token>; 16]>>::push
Unexecuted instantiation: <smallvec::SmallVec<[base::wait_context::TriggeredEvent<<devices::virtio::vhost_user_frontend::worker::Worker>::run::Token>; 16]>>::push
Unexecuted instantiation: <smallvec::SmallVec<[base::wait_context::TriggeredEvent<<devices::virtio::vhost::worker::Worker<_>>::run::Token>; 16]>>::push
Unexecuted instantiation: <smallvec::SmallVec<[base::wait_context::TriggeredEvent<<devices::pci::coiommu::PinWorker>::run::Token>; 16]>>::push
Unexecuted instantiation: <smallvec::SmallVec<[base::wait_context::TriggeredEvent<<devices::pci::coiommu::UnpinWorker>::run::Token>; 16]>>::push
Unexecuted instantiation: <smallvec::SmallVec<[base::wait_context::TriggeredEvent<<devices::pci::vfio_pci::VfioPciWorker>::run::Token>; 16]>>::push
Unexecuted instantiation: <smallvec::SmallVec<[base::wait_context::TriggeredEvent<<devices::virtio::fs::worker::Worker<_>>::run::Token>; 16]>>::push
Unexecuted instantiation: <smallvec::SmallVec<[base::wait_context::TriggeredEvent<<devices::virtio::wl::Worker>::run::Token>; 16]>>::push
Unexecuted instantiation: <smallvec::SmallVec<[base::wait_context::TriggeredEvent<devices::virtcpufreq_v2::vcpufreq_worker_thread::Token>; 16]>>::push
Unexecuted instantiation: <smallvec::SmallVec<[base::wait_context::TriggeredEvent<devices::acpi::run_worker::Token>; 16]>>::push
Unexecuted instantiation: <smallvec::SmallVec<[base::wait_context::TriggeredEvent<devices::cmos::run_cmos_worker::Token>; 16]>>::push
Unexecuted instantiation: <smallvec::SmallVec<[base::wait_context::TriggeredEvent<devices::virtio::interrupt::interrupt_resample_thread::Token>; 16]>>::push
Unexecuted instantiation: <smallvec::SmallVec<[base::wait_context::TriggeredEvent<devices::virtio::console::sys::linux::read_input::Token>; 16]>>::push
Unexecuted instantiation: <smallvec::SmallVec<[base::wait_context::TriggeredEvent<u32>; 16]>>::push
Unexecuted instantiation: <smallvec::SmallVec<[base::volatile_memory::VolatileSlice; 16]>>::push
<smallvec::SmallVec<[cros_async::mem::MemRegion; 2]>>::push
Line
Count
Source
833
1.68M
    pub fn push(&mut self, value: A::Item) {
834
        unsafe {
835
1.68M
            let (mut ptr, mut len, cap) = self.triple_mut();
836
1.68M
            if *len == cap {
837
232k
                self.reserve(1);
838
232k
                let &mut (heap_ptr, ref mut heap_len) = self.data.heap_mut();
839
232k
                ptr = heap_ptr;
840
232k
                len = heap_len;
841
1.44M
            }
842
1.68M
            ptr::write(ptr.add(*len), value);
843
1.68M
            *len += 1;
844
        }
845
1.68M
    }
Unexecuted instantiation: <smallvec::SmallVec<[base::wait_context::TriggeredEvent<metrics::controller::MetricsControllerToken>; 16]>>::push
Unexecuted instantiation: <smallvec::SmallVec<[base::wait_context::TriggeredEvent<usize>; 16]>>::push
846
847
    /// Remove an item from the end of the vector and return it, or None if empty.
848
    #[inline]
849
0
    pub fn pop(&mut self) -> Option<A::Item> {
850
        unsafe {
851
0
            let (ptr, len_ptr, _) = self.triple_mut();
852
0
            if *len_ptr == 0 {
853
0
                return None;
854
0
            }
855
0
            let last_index = *len_ptr - 1;
856
0
            *len_ptr = last_index;
857
0
            Some(ptr::read(ptr.add(last_index)))
858
        }
859
0
    }
860
861
    /// Moves all the elements of `other` into `self`, leaving `other` empty.
862
    ///
863
    /// # Example
864
    ///
865
    /// ```
866
    /// # use smallvec::{SmallVec, smallvec};
867
    /// let mut v0: SmallVec<[u8; 16]> = smallvec![1, 2, 3];
868
    /// let mut v1: SmallVec<[u8; 32]> = smallvec![4, 5, 6];
869
    /// v0.append(&mut v1);
870
    /// assert_eq!(*v0, [1, 2, 3, 4, 5, 6]);
871
    /// assert_eq!(*v1, []);
872
    /// ```
873
0
    pub fn append<B>(&mut self, other: &mut SmallVec<B>)
874
0
    where
875
0
        B: Array<Item = A::Item>,
876
    {
877
0
        self.extend(other.drain(..))
878
0
    }
879
880
    /// Re-allocate to set the capacity to `max(new_cap, inline_size())`.
881
    ///
882
    /// Panics if `new_cap` is less than the vector's length
883
    /// or if the capacity computation overflows `usize`.
884
0
    pub fn grow(&mut self, new_cap: usize) {
885
0
        infallible(self.try_grow(new_cap))
886
0
    }
887
888
    /// Re-allocate to set the capacity to `max(new_cap, inline_size())`.
889
    ///
890
    /// Panics if `new_cap` is less than the vector's length
891
235k
    pub fn try_grow(&mut self, new_cap: usize) -> Result<(), CollectionAllocErr> {
892
        unsafe {
893
235k
            let (ptr, &mut len, cap) = self.triple_mut();
894
235k
            let unspilled = !self.spilled();
895
235k
            assert!(new_cap >= len);
896
235k
            if new_cap <= self.inline_size() {
897
0
                if unspilled {
898
0
                    return Ok(());
899
0
                }
900
0
                self.data = SmallVecData::from_inline(MaybeUninit::uninit());
901
0
                ptr::copy_nonoverlapping(ptr, self.data.inline_mut(), len);
902
0
                self.capacity = len;
903
0
                deallocate(ptr, cap);
904
235k
            } else if new_cap != cap {
905
235k
                let layout = layout_array::<A::Item>(new_cap)?;
906
235k
                debug_assert!(layout.size() > 0);
907
                let new_alloc;
908
235k
                if unspilled {
909
235k
                    new_alloc = NonNull::new(alloc::alloc::alloc(layout))
910
235k
                        .ok_or(CollectionAllocErr::AllocErr { layout })?
911
235k
                        .cast()
912
235k
                        .as_ptr();
913
235k
                    ptr::copy_nonoverlapping(ptr, new_alloc, len);
914
                } else {
915
                    // This should never fail since the same succeeded
916
                    // when previously allocating `ptr`.
917
34
                    let old_layout = layout_array::<A::Item>(cap)?;
918
919
34
                    let new_ptr = alloc::alloc::realloc(ptr as *mut u8, old_layout, layout.size());
920
34
                    new_alloc = NonNull::new(new_ptr)
921
34
                        .ok_or(CollectionAllocErr::AllocErr { layout })?
922
34
                        .cast()
923
34
                        .as_ptr();
924
                }
925
235k
                self.data = SmallVecData::from_heap(new_alloc, len);
926
235k
                self.capacity = new_cap;
927
0
            }
928
235k
            Ok(())
929
        }
930
235k
    }
Unexecuted instantiation: <smallvec::SmallVec<_>>::try_grow
Unexecuted instantiation: <smallvec::SmallVec<[base::wait_context::TriggeredEvent<<devices::serial::Serial>::spawn_input_thread::{closure#0}::Token>; 16]>>::try_grow
Unexecuted instantiation: <smallvec::SmallVec<[base::wait_context::TriggeredEvent<devices::bat::Token>; 16]>>::try_grow
Unexecuted instantiation: <smallvec::SmallVec<[base::wait_context::TriggeredEvent<devices::pit::Token>; 16]>>::try_grow
Unexecuted instantiation: <smallvec::SmallVec<[base::wait_context::TriggeredEvent<devices::virtio::console::worker::Token>; 16]>>::try_grow
Unexecuted instantiation: <smallvec::SmallVec<[base::wait_context::TriggeredEvent<<devices::vmwdt::Vmwdt>::vmwdt_worker_thread::Token>; 16]>>::try_grow
Unexecuted instantiation: <smallvec::SmallVec<[base::wait_context::TriggeredEvent<<devices::virtio::p9::Worker>::run::Token>; 16]>>::try_grow
Unexecuted instantiation: <smallvec::SmallVec<[base::wait_context::TriggeredEvent<<devices::virtio::rng::Worker>::run::Token>; 16]>>::try_grow
Unexecuted instantiation: <smallvec::SmallVec<[base::wait_context::TriggeredEvent<<devices::virtio::vhost_user_frontend::worker::Worker>::run::Token>; 16]>>::try_grow
Unexecuted instantiation: <smallvec::SmallVec<[base::wait_context::TriggeredEvent<<devices::virtio::vhost::worker::Worker<_>>::run::Token>; 16]>>::try_grow
Unexecuted instantiation: <smallvec::SmallVec<[base::wait_context::TriggeredEvent<<devices::pci::coiommu::PinWorker>::run::Token>; 16]>>::try_grow
Unexecuted instantiation: <smallvec::SmallVec<[base::wait_context::TriggeredEvent<<devices::pci::coiommu::UnpinWorker>::run::Token>; 16]>>::try_grow
Unexecuted instantiation: <smallvec::SmallVec<[base::wait_context::TriggeredEvent<<devices::pci::vfio_pci::VfioPciWorker>::run::Token>; 16]>>::try_grow
Unexecuted instantiation: <smallvec::SmallVec<[base::wait_context::TriggeredEvent<<devices::virtio::fs::worker::Worker<_>>::run::Token>; 16]>>::try_grow
Unexecuted instantiation: <smallvec::SmallVec<[base::wait_context::TriggeredEvent<<devices::virtio::wl::Worker>::run::Token>; 16]>>::try_grow
Unexecuted instantiation: <smallvec::SmallVec<[base::wait_context::TriggeredEvent<devices::virtcpufreq_v2::vcpufreq_worker_thread::Token>; 16]>>::try_grow
Unexecuted instantiation: <smallvec::SmallVec<[base::wait_context::TriggeredEvent<devices::acpi::run_worker::Token>; 16]>>::try_grow
Unexecuted instantiation: <smallvec::SmallVec<[base::wait_context::TriggeredEvent<devices::cmos::run_cmos_worker::Token>; 16]>>::try_grow
Unexecuted instantiation: <smallvec::SmallVec<[base::wait_context::TriggeredEvent<devices::virtio::interrupt::interrupt_resample_thread::Token>; 16]>>::try_grow
Unexecuted instantiation: <smallvec::SmallVec<[base::wait_context::TriggeredEvent<devices::virtio::console::sys::linux::read_input::Token>; 16]>>::try_grow
Unexecuted instantiation: <smallvec::SmallVec<[base::wait_context::TriggeredEvent<u32>; 16]>>::try_grow
Unexecuted instantiation: <smallvec::SmallVec<[base::volatile_memory::VolatileSlice; 16]>>::try_grow
<smallvec::SmallVec<[cros_async::mem::MemRegion; 2]>>::try_grow
Line
Count
Source
891
235k
    pub fn try_grow(&mut self, new_cap: usize) -> Result<(), CollectionAllocErr> {
892
        unsafe {
893
235k
            let (ptr, &mut len, cap) = self.triple_mut();
894
235k
            let unspilled = !self.spilled();
895
235k
            assert!(new_cap >= len);
896
235k
            if new_cap <= self.inline_size() {
897
0
                if unspilled {
898
0
                    return Ok(());
899
0
                }
900
0
                self.data = SmallVecData::from_inline(MaybeUninit::uninit());
901
0
                ptr::copy_nonoverlapping(ptr, self.data.inline_mut(), len);
902
0
                self.capacity = len;
903
0
                deallocate(ptr, cap);
904
235k
            } else if new_cap != cap {
905
235k
                let layout = layout_array::<A::Item>(new_cap)?;
906
235k
                debug_assert!(layout.size() > 0);
907
                let new_alloc;
908
235k
                if unspilled {
909
235k
                    new_alloc = NonNull::new(alloc::alloc::alloc(layout))
910
235k
                        .ok_or(CollectionAllocErr::AllocErr { layout })?
911
235k
                        .cast()
912
235k
                        .as_ptr();
913
235k
                    ptr::copy_nonoverlapping(ptr, new_alloc, len);
914
                } else {
915
                    // This should never fail since the same succeeded
916
                    // when previously allocating `ptr`.
917
34
                    let old_layout = layout_array::<A::Item>(cap)?;
918
919
34
                    let new_ptr = alloc::alloc::realloc(ptr as *mut u8, old_layout, layout.size());
920
34
                    new_alloc = NonNull::new(new_ptr)
921
34
                        .ok_or(CollectionAllocErr::AllocErr { layout })?
922
34
                        .cast()
923
34
                        .as_ptr();
924
                }
925
235k
                self.data = SmallVecData::from_heap(new_alloc, len);
926
235k
                self.capacity = new_cap;
927
0
            }
928
235k
            Ok(())
929
        }
930
235k
    }
Unexecuted instantiation: <smallvec::SmallVec<[base::wait_context::TriggeredEvent<metrics::controller::MetricsControllerToken>; 16]>>::try_grow
Unexecuted instantiation: <smallvec::SmallVec<[base::wait_context::TriggeredEvent<usize>; 16]>>::try_grow
931
932
    /// Reserve capacity for `additional` more elements to be inserted.
933
    ///
934
    /// May reserve more space to avoid frequent reallocations.
935
    ///
936
    /// Panics if the capacity computation overflows `usize`.
937
    #[inline]
938
1.12M
    pub fn reserve(&mut self, additional: usize) {
939
1.12M
        infallible(self.try_reserve(additional))
940
1.12M
    }
Unexecuted instantiation: <smallvec::SmallVec<_>>::reserve
Unexecuted instantiation: <smallvec::SmallVec<[base::wait_context::TriggeredEvent<<devices::serial::Serial>::spawn_input_thread::{closure#0}::Token>; 16]>>::reserve
Unexecuted instantiation: <smallvec::SmallVec<[base::wait_context::TriggeredEvent<devices::bat::Token>; 16]>>::reserve
Unexecuted instantiation: <smallvec::SmallVec<[base::wait_context::TriggeredEvent<devices::pit::Token>; 16]>>::reserve
Unexecuted instantiation: <smallvec::SmallVec<[base::wait_context::TriggeredEvent<devices::virtio::console::worker::Token>; 16]>>::reserve
Unexecuted instantiation: <smallvec::SmallVec<[base::wait_context::TriggeredEvent<<devices::vmwdt::Vmwdt>::vmwdt_worker_thread::Token>; 16]>>::reserve
Unexecuted instantiation: <smallvec::SmallVec<[base::wait_context::TriggeredEvent<<devices::virtio::p9::Worker>::run::Token>; 16]>>::reserve
Unexecuted instantiation: <smallvec::SmallVec<[base::wait_context::TriggeredEvent<<devices::virtio::rng::Worker>::run::Token>; 16]>>::reserve
Unexecuted instantiation: <smallvec::SmallVec<[base::wait_context::TriggeredEvent<<devices::virtio::vhost_user_frontend::worker::Worker>::run::Token>; 16]>>::reserve
Unexecuted instantiation: <smallvec::SmallVec<[base::wait_context::TriggeredEvent<<devices::virtio::vhost::worker::Worker<_>>::run::Token>; 16]>>::reserve
Unexecuted instantiation: <smallvec::SmallVec<[base::wait_context::TriggeredEvent<<devices::pci::coiommu::PinWorker>::run::Token>; 16]>>::reserve
Unexecuted instantiation: <smallvec::SmallVec<[base::wait_context::TriggeredEvent<<devices::pci::coiommu::UnpinWorker>::run::Token>; 16]>>::reserve
Unexecuted instantiation: <smallvec::SmallVec<[base::wait_context::TriggeredEvent<<devices::pci::vfio_pci::VfioPciWorker>::run::Token>; 16]>>::reserve
Unexecuted instantiation: <smallvec::SmallVec<[base::wait_context::TriggeredEvent<<devices::virtio::fs::worker::Worker<_>>::run::Token>; 16]>>::reserve
Unexecuted instantiation: <smallvec::SmallVec<[base::wait_context::TriggeredEvent<<devices::virtio::wl::Worker>::run::Token>; 16]>>::reserve
Unexecuted instantiation: <smallvec::SmallVec<[base::wait_context::TriggeredEvent<devices::virtcpufreq_v2::vcpufreq_worker_thread::Token>; 16]>>::reserve
Unexecuted instantiation: <smallvec::SmallVec<[base::wait_context::TriggeredEvent<devices::acpi::run_worker::Token>; 16]>>::reserve
Unexecuted instantiation: <smallvec::SmallVec<[base::wait_context::TriggeredEvent<devices::cmos::run_cmos_worker::Token>; 16]>>::reserve
Unexecuted instantiation: <smallvec::SmallVec<[base::wait_context::TriggeredEvent<devices::virtio::interrupt::interrupt_resample_thread::Token>; 16]>>::reserve
Unexecuted instantiation: <smallvec::SmallVec<[base::wait_context::TriggeredEvent<devices::virtio::console::sys::linux::read_input::Token>; 16]>>::reserve
Unexecuted instantiation: <smallvec::SmallVec<[base::wait_context::TriggeredEvent<u32>; 16]>>::reserve
<smallvec::SmallVec<[base::volatile_memory::VolatileSlice; 16]>>::reserve
Line
Count
Source
938
654k
    pub fn reserve(&mut self, additional: usize) {
939
654k
        infallible(self.try_reserve(additional))
940
654k
    }
<smallvec::SmallVec<[cros_async::mem::MemRegion; 2]>>::reserve
Line
Count
Source
938
471k
    pub fn reserve(&mut self, additional: usize) {
939
471k
        infallible(self.try_reserve(additional))
940
471k
    }
Unexecuted instantiation: <smallvec::SmallVec<[base::wait_context::TriggeredEvent<metrics::controller::MetricsControllerToken>; 16]>>::reserve
Unexecuted instantiation: <smallvec::SmallVec<[base::wait_context::TriggeredEvent<usize>; 16]>>::reserve
941
942
    /// Reserve capacity for `additional` more elements to be inserted.
943
    ///
944
    /// May reserve more space to avoid frequent reallocations.
945
1.12M
    pub fn try_reserve(&mut self, additional: usize) -> Result<(), CollectionAllocErr> {
946
        // prefer triple_mut() even if triple() would work
947
        // so that the optimizer removes duplicated calls to it
948
        // from callers like insert()
949
1.12M
        let (_, &mut len, cap) = self.triple_mut();
950
1.12M
        if cap - len >= additional {
951
890k
            return Ok(());
952
235k
        }
953
235k
        let new_cap = len
954
235k
            .checked_add(additional)
955
235k
            .and_then(usize::checked_next_power_of_two)
956
235k
            .ok_or(CollectionAllocErr::CapacityOverflow)?;
957
235k
        self.try_grow(new_cap)
958
1.12M
    }
Unexecuted instantiation: <smallvec::SmallVec<_>>::try_reserve
Unexecuted instantiation: <smallvec::SmallVec<[base::wait_context::TriggeredEvent<<devices::serial::Serial>::spawn_input_thread::{closure#0}::Token>; 16]>>::try_reserve
Unexecuted instantiation: <smallvec::SmallVec<[base::wait_context::TriggeredEvent<devices::bat::Token>; 16]>>::try_reserve
Unexecuted instantiation: <smallvec::SmallVec<[base::wait_context::TriggeredEvent<devices::pit::Token>; 16]>>::try_reserve
Unexecuted instantiation: <smallvec::SmallVec<[base::wait_context::TriggeredEvent<devices::virtio::console::worker::Token>; 16]>>::try_reserve
Unexecuted instantiation: <smallvec::SmallVec<[base::wait_context::TriggeredEvent<<devices::vmwdt::Vmwdt>::vmwdt_worker_thread::Token>; 16]>>::try_reserve
Unexecuted instantiation: <smallvec::SmallVec<[base::wait_context::TriggeredEvent<<devices::virtio::p9::Worker>::run::Token>; 16]>>::try_reserve
Unexecuted instantiation: <smallvec::SmallVec<[base::wait_context::TriggeredEvent<<devices::virtio::rng::Worker>::run::Token>; 16]>>::try_reserve
Unexecuted instantiation: <smallvec::SmallVec<[base::wait_context::TriggeredEvent<<devices::virtio::vhost_user_frontend::worker::Worker>::run::Token>; 16]>>::try_reserve
Unexecuted instantiation: <smallvec::SmallVec<[base::wait_context::TriggeredEvent<<devices::virtio::vhost::worker::Worker<_>>::run::Token>; 16]>>::try_reserve
Unexecuted instantiation: <smallvec::SmallVec<[base::wait_context::TriggeredEvent<<devices::pci::coiommu::PinWorker>::run::Token>; 16]>>::try_reserve
Unexecuted instantiation: <smallvec::SmallVec<[base::wait_context::TriggeredEvent<<devices::pci::coiommu::UnpinWorker>::run::Token>; 16]>>::try_reserve
Unexecuted instantiation: <smallvec::SmallVec<[base::wait_context::TriggeredEvent<<devices::pci::vfio_pci::VfioPciWorker>::run::Token>; 16]>>::try_reserve
Unexecuted instantiation: <smallvec::SmallVec<[base::wait_context::TriggeredEvent<<devices::virtio::fs::worker::Worker<_>>::run::Token>; 16]>>::try_reserve
Unexecuted instantiation: <smallvec::SmallVec<[base::wait_context::TriggeredEvent<<devices::virtio::wl::Worker>::run::Token>; 16]>>::try_reserve
Unexecuted instantiation: <smallvec::SmallVec<[base::wait_context::TriggeredEvent<devices::virtcpufreq_v2::vcpufreq_worker_thread::Token>; 16]>>::try_reserve
Unexecuted instantiation: <smallvec::SmallVec<[base::wait_context::TriggeredEvent<devices::acpi::run_worker::Token>; 16]>>::try_reserve
Unexecuted instantiation: <smallvec::SmallVec<[base::wait_context::TriggeredEvent<devices::cmos::run_cmos_worker::Token>; 16]>>::try_reserve
Unexecuted instantiation: <smallvec::SmallVec<[base::wait_context::TriggeredEvent<devices::virtio::interrupt::interrupt_resample_thread::Token>; 16]>>::try_reserve
Unexecuted instantiation: <smallvec::SmallVec<[base::wait_context::TriggeredEvent<devices::virtio::console::sys::linux::read_input::Token>; 16]>>::try_reserve
Unexecuted instantiation: <smallvec::SmallVec<[base::wait_context::TriggeredEvent<u32>; 16]>>::try_reserve
<smallvec::SmallVec<[base::volatile_memory::VolatileSlice; 16]>>::try_reserve
Line
Count
Source
945
654k
    pub fn try_reserve(&mut self, additional: usize) -> Result<(), CollectionAllocErr> {
946
        // prefer triple_mut() even if triple() would work
947
        // so that the optimizer removes duplicated calls to it
948
        // from callers like insert()
949
654k
        let (_, &mut len, cap) = self.triple_mut();
950
654k
        if cap - len >= additional {
951
654k
            return Ok(());
952
0
        }
953
0
        let new_cap = len
954
0
            .checked_add(additional)
955
0
            .and_then(usize::checked_next_power_of_two)
956
0
            .ok_or(CollectionAllocErr::CapacityOverflow)?;
957
0
        self.try_grow(new_cap)
958
654k
    }
<smallvec::SmallVec<[cros_async::mem::MemRegion; 2]>>::try_reserve
Line
Count
Source
945
471k
    pub fn try_reserve(&mut self, additional: usize) -> Result<(), CollectionAllocErr> {
946
        // prefer triple_mut() even if triple() would work
947
        // so that the optimizer removes duplicated calls to it
948
        // from callers like insert()
949
471k
        let (_, &mut len, cap) = self.triple_mut();
950
471k
        if cap - len >= additional {
951
236k
            return Ok(());
952
235k
        }
953
235k
        let new_cap = len
954
235k
            .checked_add(additional)
955
235k
            .and_then(usize::checked_next_power_of_two)
956
235k
            .ok_or(CollectionAllocErr::CapacityOverflow)?;
957
235k
        self.try_grow(new_cap)
958
471k
    }
Unexecuted instantiation: <smallvec::SmallVec<[base::wait_context::TriggeredEvent<metrics::controller::MetricsControllerToken>; 16]>>::try_reserve
Unexecuted instantiation: <smallvec::SmallVec<[base::wait_context::TriggeredEvent<usize>; 16]>>::try_reserve
959
960
    /// Reserve the minimum capacity for `additional` more elements to be inserted.
961
    ///
962
    /// Panics if the new capacity overflows `usize`.
963
0
    pub fn reserve_exact(&mut self, additional: usize) {
964
0
        infallible(self.try_reserve_exact(additional))
965
0
    }
966
967
    /// Reserve the minimum capacity for `additional` more elements to be inserted.
968
0
    pub fn try_reserve_exact(&mut self, additional: usize) -> Result<(), CollectionAllocErr> {
969
0
        let (_, &mut len, cap) = self.triple_mut();
970
0
        if cap - len >= additional {
971
0
            return Ok(());
972
0
        }
973
0
        let new_cap = len
974
0
            .checked_add(additional)
975
0
            .ok_or(CollectionAllocErr::CapacityOverflow)?;
976
0
        self.try_grow(new_cap)
977
0
    }
978
979
    /// Shrink the capacity of the vector as much as possible.
980
    ///
981
    /// When possible, this will move data from an external heap buffer to the vector's inline
982
    /// storage.
983
0
    pub fn shrink_to_fit(&mut self) {
984
0
        if !self.spilled() {
985
0
            return;
986
0
        }
987
0
        let len = self.len();
988
0
        if self.inline_size() >= len {
989
0
            unsafe {
990
0
                let (ptr, len) = self.data.heap();
991
0
                self.data = SmallVecData::from_inline(MaybeUninit::uninit());
992
0
                ptr::copy_nonoverlapping(ptr, self.data.inline_mut(), len);
993
0
                deallocate(ptr, self.capacity);
994
0
                self.capacity = len;
995
0
            }
996
0
        } else if self.capacity() > len {
997
0
            self.grow(len);
998
0
        }
999
0
    }
1000
1001
    /// Shorten the vector, keeping the first `len` elements and dropping the rest.
1002
    ///
1003
    /// If `len` is greater than or equal to the vector's current length, this has no
1004
    /// effect.
1005
    ///
1006
    /// This does not re-allocate.  If you want the vector's capacity to shrink, call
1007
    /// `shrink_to_fit` after truncating.
1008
239k
    pub fn truncate(&mut self, len: usize) {
1009
        unsafe {
1010
239k
            let (ptr, len_ptr, _) = self.triple_mut();
1011
239k
            while len < *len_ptr {
1012
0
                let last_index = *len_ptr - 1;
1013
0
                *len_ptr = last_index;
1014
0
                ptr::drop_in_place(ptr.add(last_index));
1015
0
            }
1016
        }
1017
239k
    }
Unexecuted instantiation: <smallvec::SmallVec<_>>::truncate
<smallvec::SmallVec<[cros_async::mem::MemRegion; 2]>>::truncate
Line
Count
Source
1008
239k
    pub fn truncate(&mut self, len: usize) {
1009
        unsafe {
1010
239k
            let (ptr, len_ptr, _) = self.triple_mut();
1011
239k
            while len < *len_ptr {
1012
0
                let last_index = *len_ptr - 1;
1013
0
                *len_ptr = last_index;
1014
0
                ptr::drop_in_place(ptr.add(last_index));
1015
0
            }
1016
        }
1017
239k
    }
1018
1019
    /// Extracts a slice containing the entire vector.
1020
    ///
1021
    /// Equivalent to `&s[..]`.
1022
239k
    pub fn as_slice(&self) -> &[A::Item] {
1023
239k
        self
1024
239k
    }
Unexecuted instantiation: <smallvec::SmallVec<_>>::as_slice
<smallvec::SmallVec<[cros_async::mem::MemRegion; 2]>>::as_slice
Line
Count
Source
1022
239k
    pub fn as_slice(&self) -> &[A::Item] {
1023
239k
        self
1024
239k
    }
1025
1026
    /// Extracts a mutable slice of the entire vector.
1027
    ///
1028
    /// Equivalent to `&mut s[..]`.
1029
0
    pub fn as_mut_slice(&mut self) -> &mut [A::Item] {
1030
0
        self
1031
0
    }
1032
1033
    /// Remove the element at position `index`, replacing it with the last element.
1034
    ///
1035
    /// This does not preserve ordering, but is O(1).
1036
    ///
1037
    /// Panics if `index` is out of bounds.
1038
    #[inline]
1039
0
    pub fn swap_remove(&mut self, index: usize) -> A::Item {
1040
0
        let len = self.len();
1041
0
        self.swap(len - 1, index);
1042
0
        self.pop()
1043
0
            .unwrap_or_else(|| unsafe { unreachable_unchecked() })
1044
0
    }
1045
1046
    /// Remove all elements from the vector.
1047
    #[inline]
1048
0
    pub fn clear(&mut self) {
1049
0
        self.truncate(0);
1050
0
    }
1051
1052
    /// Remove and return the element at position `index`, shifting all elements after it to the
1053
    /// left.
1054
    ///
1055
    /// Panics if `index` is out of bounds.
1056
0
    pub fn remove(&mut self, index: usize) -> A::Item {
1057
        unsafe {
1058
0
            let (mut ptr, len_ptr, _) = self.triple_mut();
1059
0
            let len = *len_ptr;
1060
0
            assert!(index < len);
1061
0
            *len_ptr = len - 1;
1062
0
            ptr = ptr.add(index);
1063
0
            let item = ptr::read(ptr);
1064
0
            ptr::copy(ptr.add(1), ptr, len - index - 1);
1065
0
            item
1066
        }
1067
0
    }
1068
1069
    /// Insert an element at position `index`, shifting all elements after it to the right.
1070
    ///
1071
    /// Panics if `index > len`.
1072
0
    pub fn insert(&mut self, index: usize, element: A::Item) {
1073
0
        self.reserve(1);
1074
1075
        unsafe {
1076
0
            let (mut ptr, len_ptr, _) = self.triple_mut();
1077
0
            let len = *len_ptr;
1078
0
            ptr = ptr.add(index);
1079
0
            if index < len {
1080
0
                ptr::copy(ptr, ptr.add(1), len - index);
1081
0
            } else if index == len {
1082
0
                // No elements need shifting.
1083
0
            } else {
1084
0
                panic!("index exceeds length");
1085
            }
1086
0
            *len_ptr = len + 1;
1087
0
            ptr::write(ptr, element);
1088
        }
1089
0
    }
1090
1091
    /// Insert multiple elements at position `index`, shifting all following elements toward the
1092
    /// back.
1093
0
    pub fn insert_many<I: IntoIterator<Item = A::Item>>(&mut self, index: usize, iterable: I) {
1094
0
        let mut iter = iterable.into_iter();
1095
0
        if index == self.len() {
1096
0
            return self.extend(iter);
1097
0
        }
1098
1099
0
        let (lower_size_bound, _) = iter.size_hint();
1100
0
        assert!(lower_size_bound <= core::isize::MAX as usize); // Ensure offset is indexable
1101
0
        assert!(index + lower_size_bound >= index); // Protect against overflow
1102
1103
0
        let mut num_added = 0;
1104
0
        let old_len = self.len();
1105
0
        assert!(index <= old_len);
1106
1107
        unsafe {
1108
            // Reserve space for `lower_size_bound` elements.
1109
0
            self.reserve(lower_size_bound);
1110
0
            let start = self.as_mut_ptr();
1111
0
            let ptr = start.add(index);
1112
1113
            // Move the trailing elements.
1114
0
            ptr::copy(ptr, ptr.add(lower_size_bound), old_len - index);
1115
1116
            // In case the iterator panics, don't double-drop the items we just copied above.
1117
0
            self.set_len(0);
1118
0
            let mut guard = DropOnPanic {
1119
0
                start,
1120
0
                skip: index..(index + lower_size_bound),
1121
0
                len: old_len + lower_size_bound,
1122
0
            };
1123
1124
            // The set_len above invalidates the previous pointers, so we must re-create them.
1125
0
            let start = self.as_mut_ptr();
1126
0
            let ptr = start.add(index);
1127
1128
0
            while num_added < lower_size_bound {
1129
0
                let element = match iter.next() {
1130
0
                    Some(x) => x,
1131
0
                    None => break,
1132
                };
1133
0
                let cur = ptr.add(num_added);
1134
0
                ptr::write(cur, element);
1135
0
                guard.skip.start += 1;
1136
0
                num_added += 1;
1137
            }
1138
1139
0
            if num_added < lower_size_bound {
1140
0
                // Iterator provided fewer elements than the hint. Move the tail backward.
1141
0
                ptr::copy(
1142
0
                    ptr.add(lower_size_bound),
1143
0
                    ptr.add(num_added),
1144
0
                    old_len - index,
1145
0
                );
1146
0
            }
1147
            // There are no more duplicate or uninitialized slots, so the guard is not needed.
1148
0
            self.set_len(old_len + num_added);
1149
0
            mem::forget(guard);
1150
        }
1151
1152
        // Insert any remaining elements one-by-one.
1153
0
        for element in iter {
1154
0
            self.insert(index + num_added, element);
1155
0
            num_added += 1;
1156
0
        }
1157
1158
        struct DropOnPanic<T> {
1159
            start: *mut T,
1160
            skip: Range<usize>, // Space we copied-out-of, but haven't written-to yet.
1161
            len: usize,
1162
        }
1163
1164
        impl<T> Drop for DropOnPanic<T> {
1165
0
            fn drop(&mut self) {
1166
0
                for i in 0..self.len {
1167
0
                    if !self.skip.contains(&i) {
1168
0
                        unsafe {
1169
0
                            ptr::drop_in_place(self.start.add(i));
1170
0
                        }
1171
0
                    }
1172
                }
1173
0
            }
1174
        }
1175
0
    }
1176
1177
    /// Convert a SmallVec to a Vec, without reallocating if the SmallVec has already spilled onto
1178
    /// the heap.
1179
0
    pub fn into_vec(self) -> Vec<A::Item> {
1180
0
        if self.spilled() {
1181
            unsafe {
1182
0
                let (ptr, len) = self.data.heap();
1183
0
                let v = Vec::from_raw_parts(ptr, len, self.capacity);
1184
0
                mem::forget(self);
1185
0
                v
1186
            }
1187
        } else {
1188
0
            self.into_iter().collect()
1189
        }
1190
0
    }
1191
1192
    /// Converts a `SmallVec` into a `Box<[T]>` without reallocating if the `SmallVec` has already spilled
1193
    /// onto the heap.
1194
    ///
1195
    /// Note that this will drop any excess capacity.
1196
0
    pub fn into_boxed_slice(self) -> Box<[A::Item]> {
1197
0
        self.into_vec().into_boxed_slice()
1198
0
    }
1199
1200
    /// Convert the SmallVec into an `A` if possible. Otherwise return `Err(Self)`.
1201
    ///
1202
    /// This method returns `Err(Self)` if the SmallVec is too short (and the `A` contains uninitialized elements),
1203
    /// or if the SmallVec is too long (and all the elements were spilled to the heap).
1204
0
    pub fn into_inner(self) -> Result<A, Self> {
1205
0
        if self.spilled() || self.len() != A::size() {
1206
            // Note: A::size, not Self::inline_capacity
1207
0
            Err(self)
1208
        } else {
1209
            unsafe {
1210
0
                let data = ptr::read(&self.data);
1211
0
                mem::forget(self);
1212
0
                Ok(data.into_inline().assume_init())
1213
            }
1214
        }
1215
0
    }
1216
1217
    /// Retains only the elements specified by the predicate.
1218
    ///
1219
    /// In other words, remove all elements `e` such that `f(&e)` returns `false`.
1220
    /// This method operates in place and preserves the order of the retained
1221
    /// elements.
1222
0
    pub fn retain<F: FnMut(&mut A::Item) -> bool>(&mut self, mut f: F) {
1223
0
        let mut del = 0;
1224
0
        let len = self.len();
1225
0
        for i in 0..len {
1226
0
            if !f(&mut self[i]) {
1227
0
                del += 1;
1228
0
            } else if del > 0 {
1229
0
                self.swap(i - del, i);
1230
0
            }
1231
        }
1232
0
        self.truncate(len - del);
1233
0
    }
1234
1235
    /// Retains only the elements specified by the predicate.
1236
    ///
1237
    /// This method is identical in behaviour to [`retain`]; it is included only
1238
    /// to maintain api-compatability with `std::Vec`, where the methods are
1239
    /// separate for historical reasons.
1240
0
    pub fn retain_mut<F: FnMut(&mut A::Item) -> bool>(&mut self, f: F) {
1241
0
        self.retain(f)
1242
0
    }
1243
1244
    /// Removes consecutive duplicate elements.
1245
0
    pub fn dedup(&mut self)
1246
0
    where
1247
0
        A::Item: PartialEq<A::Item>,
1248
    {
1249
0
        self.dedup_by(|a, b| a == b);
1250
0
    }
1251
1252
    /// Removes consecutive duplicate elements using the given equality relation.
1253
0
    pub fn dedup_by<F>(&mut self, mut same_bucket: F)
1254
0
    where
1255
0
        F: FnMut(&mut A::Item, &mut A::Item) -> bool,
1256
    {
1257
        // See the implementation of Vec::dedup_by in the
1258
        // standard library for an explanation of this algorithm.
1259
0
        let len = self.len();
1260
0
        if len <= 1 {
1261
0
            return;
1262
0
        }
1263
1264
0
        let ptr = self.as_mut_ptr();
1265
0
        let mut w: usize = 1;
1266
1267
        unsafe {
1268
0
            for r in 1..len {
1269
0
                let p_r = ptr.add(r);
1270
0
                let p_wm1 = ptr.add(w - 1);
1271
0
                if !same_bucket(&mut *p_r, &mut *p_wm1) {
1272
0
                    if r != w {
1273
0
                        let p_w = p_wm1.add(1);
1274
0
                        mem::swap(&mut *p_r, &mut *p_w);
1275
0
                    }
1276
0
                    w += 1;
1277
0
                }
1278
            }
1279
        }
1280
1281
0
        self.truncate(w);
1282
0
    }
1283
1284
    /// Removes consecutive elements that map to the same key.
1285
0
    pub fn dedup_by_key<F, K>(&mut self, mut key: F)
1286
0
    where
1287
0
        F: FnMut(&mut A::Item) -> K,
1288
0
        K: PartialEq<K>,
1289
    {
1290
0
        self.dedup_by(|a, b| key(a) == key(b));
1291
0
    }
1292
1293
    /// Resizes the `SmallVec` in-place so that `len` is equal to `new_len`.
1294
    ///
1295
    /// If `new_len` is greater than `len`, the `SmallVec` is extended by the difference, with each
1296
    /// additional slot filled with the result of calling the closure `f`. The return values from `f`
1297
    //// will end up in the `SmallVec` in the order they have been generated.
1298
    ///
1299
    /// If `new_len` is less than `len`, the `SmallVec` is simply truncated.
1300
    ///
1301
    /// This method uses a closure to create new values on every push. If you'd rather `Clone` a given
1302
    /// value, use `resize`. If you want to use the `Default` trait to generate values, you can pass
1303
    /// `Default::default()` as the second argument.
1304
    ///
1305
    /// Added for std::vec::Vec compatibility (added in Rust 1.33.0)
1306
    ///
1307
    /// ```
1308
    /// # use smallvec::{smallvec, SmallVec};
1309
    /// let mut vec : SmallVec<[_; 4]> = smallvec![1, 2, 3];
1310
    /// vec.resize_with(5, Default::default);
1311
    /// assert_eq!(&*vec, &[1, 2, 3, 0, 0]);
1312
    ///
1313
    /// let mut vec : SmallVec<[_; 4]> = smallvec![];
1314
    /// let mut p = 1;
1315
    /// vec.resize_with(4, || { p *= 2; p });
1316
    /// assert_eq!(&*vec, &[2, 4, 8, 16]);
1317
    /// ```
1318
0
    pub fn resize_with<F>(&mut self, new_len: usize, f: F)
1319
0
    where
1320
0
        F: FnMut() -> A::Item,
1321
    {
1322
0
        let old_len = self.len();
1323
0
        if old_len < new_len {
1324
0
            let mut f = f;
1325
0
            let additional = new_len - old_len;
1326
0
            self.reserve(additional);
1327
0
            for _ in 0..additional {
1328
0
                self.push(f());
1329
0
            }
1330
0
        } else if old_len > new_len {
1331
0
            self.truncate(new_len);
1332
0
        }
1333
0
    }
1334
1335
    /// Creates a `SmallVec` directly from the raw components of another
1336
    /// `SmallVec`.
1337
    ///
1338
    /// # Safety
1339
    ///
1340
    /// This is highly unsafe, due to the number of invariants that aren't
1341
    /// checked:
1342
    ///
1343
    /// * `ptr` needs to have been previously allocated via `SmallVec` for its
1344
    ///   spilled storage (at least, it's highly likely to be incorrect if it
1345
    ///   wasn't).
1346
    /// * `ptr`'s `A::Item` type needs to be the same size and alignment that
1347
    ///   it was allocated with
1348
    /// * `length` needs to be less than or equal to `capacity`.
1349
    /// * `capacity` needs to be the capacity that the pointer was allocated
1350
    ///   with.
1351
    ///
1352
    /// Violating these may cause problems like corrupting the allocator's
1353
    /// internal data structures.
1354
    ///
1355
    /// Additionally, `capacity` must be greater than the amount of inline
1356
    /// storage `A` has; that is, the new `SmallVec` must need to spill over
1357
    /// into heap allocated storage. This condition is asserted against.
1358
    ///
1359
    /// The ownership of `ptr` is effectively transferred to the
1360
    /// `SmallVec` which may then deallocate, reallocate or change the
1361
    /// contents of memory pointed to by the pointer at will. Ensure
1362
    /// that nothing else uses the pointer after calling this
1363
    /// function.
1364
    ///
1365
    /// # Examples
1366
    ///
1367
    /// ```
1368
    /// # #[macro_use] extern crate smallvec;
1369
    /// # use smallvec::SmallVec;
1370
    /// use std::mem;
1371
    /// use std::ptr;
1372
    ///
1373
    /// fn main() {
1374
    ///     let mut v: SmallVec<[_; 1]> = smallvec![1, 2, 3];
1375
    ///
1376
    ///     // Pull out the important parts of `v`.
1377
    ///     let p = v.as_mut_ptr();
1378
    ///     let len = v.len();
1379
    ///     let cap = v.capacity();
1380
    ///     let spilled = v.spilled();
1381
    ///
1382
    ///     unsafe {
1383
    ///         // Forget all about `v`. The heap allocation that stored the
1384
    ///         // three values won't be deallocated.
1385
    ///         mem::forget(v);
1386
    ///
1387
    ///         // Overwrite memory with [4, 5, 6].
1388
    ///         //
1389
    ///         // This is only safe if `spilled` is true! Otherwise, we are
1390
    ///         // writing into the old `SmallVec`'s inline storage on the
1391
    ///         // stack.
1392
    ///         assert!(spilled);
1393
    ///         for i in 0..len {
1394
    ///             ptr::write(p.add(i), 4 + i);
1395
    ///         }
1396
    ///
1397
    ///         // Put everything back together into a SmallVec with a different
1398
    ///         // amount of inline storage, but which is still less than `cap`.
1399
    ///         let rebuilt = SmallVec::<[_; 2]>::from_raw_parts(p, len, cap);
1400
    ///         assert_eq!(&*rebuilt, &[4, 5, 6]);
1401
    ///     }
1402
    /// }
1403
    #[inline]
1404
0
    pub unsafe fn from_raw_parts(ptr: *mut A::Item, length: usize, capacity: usize) -> SmallVec<A> {
1405
0
        assert!(capacity > Self::inline_capacity());
1406
0
        SmallVec {
1407
0
            capacity,
1408
0
            data: SmallVecData::from_heap(ptr, length),
1409
0
        }
1410
0
    }
1411
1412
    /// Returns a raw pointer to the vector's buffer.
1413
1.19M
    pub fn as_ptr(&self) -> *const A::Item {
1414
        // We shadow the slice method of the same name to avoid going through
1415
        // `deref`, which creates an intermediate reference that may place
1416
        // additional safety constraints on the contents of the slice.
1417
1.19M
        self.triple().0
1418
1.19M
    }
Unexecuted instantiation: <smallvec::SmallVec<_>>::as_ptr
Unexecuted instantiation: <smallvec::SmallVec<[base::wait_context::TriggeredEvent<<devices::virtio::vhost_user_frontend::worker::Worker>::run::Token>; 16]>>::as_ptr
Unexecuted instantiation: <smallvec::SmallVec<[base::wait_context::TriggeredEvent<devices::virtio::interrupt::interrupt_resample_thread::Token>; 16]>>::as_ptr
<smallvec::SmallVec<[base::volatile_memory::VolatileSlice; 16]>>::as_ptr
Line
Count
Source
1413
1.19M
    pub fn as_ptr(&self) -> *const A::Item {
1414
        // We shadow the slice method of the same name to avoid going through
1415
        // `deref`, which creates an intermediate reference that may place
1416
        // additional safety constraints on the contents of the slice.
1417
1.19M
        self.triple().0
1418
1.19M
    }
1419
1420
    /// Returns a raw mutable pointer to the vector's buffer.
1421
0
    pub fn as_mut_ptr(&mut self) -> *mut A::Item {
1422
        // We shadow the slice method of the same name to avoid going through
1423
        // `deref_mut`, which creates an intermediate reference that may place
1424
        // additional safety constraints on the contents of the slice.
1425
0
        self.triple_mut().0
1426
0
    }
1427
}
1428
1429
impl<A: Array> SmallVec<A>
1430
where
1431
    A::Item: Copy,
1432
{
1433
    /// Copy the elements from a slice into a new `SmallVec`.
1434
    ///
1435
    /// For slices of `Copy` types, this is more efficient than `SmallVec::from(slice)`.
1436
0
    pub fn from_slice(slice: &[A::Item]) -> Self {
1437
0
        let len = slice.len();
1438
0
        if len <= Self::inline_capacity() {
1439
0
            SmallVec {
1440
0
                capacity: len,
1441
0
                data: SmallVecData::from_inline(unsafe {
1442
0
                    let mut data: MaybeUninit<A> = MaybeUninit::uninit();
1443
0
                    ptr::copy_nonoverlapping(
1444
0
                        slice.as_ptr(),
1445
0
                        data.as_mut_ptr() as *mut A::Item,
1446
0
                        len,
1447
0
                    );
1448
0
                    data
1449
0
                }),
1450
0
            }
1451
        } else {
1452
0
            let mut b = slice.to_vec();
1453
0
            let (ptr, cap) = (b.as_mut_ptr(), b.capacity());
1454
0
            mem::forget(b);
1455
0
            SmallVec {
1456
0
                capacity: cap,
1457
0
                data: SmallVecData::from_heap(ptr, len),
1458
0
            }
1459
        }
1460
0
    }
Unexecuted instantiation: <smallvec::SmallVec<_>>::from_slice
Unexecuted instantiation: <smallvec::SmallVec<[devices::virtio::iommu::memory_mapper::MemRegion; 1]>>::from_slice
1461
1462
    /// Copy elements from a slice into the vector at position `index`, shifting any following
1463
    /// elements toward the back.
1464
    ///
1465
    /// For slices of `Copy` types, this is more efficient than `insert`.
1466
0
    pub fn insert_from_slice(&mut self, index: usize, slice: &[A::Item]) {
1467
0
        self.reserve(slice.len());
1468
1469
0
        let len = self.len();
1470
0
        assert!(index <= len);
1471
1472
0
        unsafe {
1473
0
            let slice_ptr = slice.as_ptr();
1474
0
            let ptr = self.as_mut_ptr().add(index);
1475
0
            ptr::copy(ptr, ptr.add(slice.len()), len - index);
1476
0
            ptr::copy_nonoverlapping(slice_ptr, ptr, slice.len());
1477
0
            self.set_len(len + slice.len());
1478
0
        }
1479
0
    }
1480
1481
    /// Copy elements from a slice and append them to the vector.
1482
    ///
1483
    /// For slices of `Copy` types, this is more efficient than `extend`.
1484
    #[inline]
1485
0
    pub fn extend_from_slice(&mut self, slice: &[A::Item]) {
1486
0
        let len = self.len();
1487
0
        self.insert_from_slice(len, slice);
1488
0
    }
1489
}
1490
1491
impl<A: Array> SmallVec<A>
1492
where
1493
    A::Item: Clone,
1494
{
1495
    /// Resizes the vector so that its length is equal to `len`.
1496
    ///
1497
    /// If `len` is less than the current length, the vector simply truncated.
1498
    ///
1499
    /// If `len` is greater than the current length, `value` is appended to the
1500
    /// vector until its length equals `len`.
1501
0
    pub fn resize(&mut self, len: usize, value: A::Item) {
1502
0
        let old_len = self.len();
1503
1504
0
        if len > old_len {
1505
0
            self.extend(repeat(value).take(len - old_len));
1506
0
        } else {
1507
0
            self.truncate(len);
1508
0
        }
1509
0
    }
1510
1511
    /// Creates a `SmallVec` with `n` copies of `elem`.
1512
    /// ```
1513
    /// use smallvec::SmallVec;
1514
    ///
1515
    /// let v = SmallVec::<[char; 128]>::from_elem('d', 2);
1516
    /// assert_eq!(v, SmallVec::from_buf(['d', 'd']));
1517
    /// ```
1518
0
    pub fn from_elem(elem: A::Item, n: usize) -> Self {
1519
0
        if n > Self::inline_capacity() {
1520
0
            vec![elem; n].into()
1521
        } else {
1522
0
            let mut v = SmallVec::<A>::new();
1523
            unsafe {
1524
0
                let (ptr, len_ptr, _) = v.triple_mut();
1525
0
                let mut local_len = SetLenOnDrop::new(len_ptr);
1526
1527
0
                for i in 0..n {
1528
0
                    ::core::ptr::write(ptr.add(i), elem.clone());
1529
0
                    local_len.increment_len(1);
1530
0
                }
1531
            }
1532
0
            v
1533
        }
1534
0
    }
1535
}
1536
1537
impl<A: Array> ops::Deref for SmallVec<A> {
1538
    type Target = [A::Item];
1539
    #[inline]
1540
7.06M
    fn deref(&self) -> &[A::Item] {
1541
        unsafe {
1542
7.06M
            let (ptr, len, _) = self.triple();
1543
7.06M
            slice::from_raw_parts(ptr, len)
1544
        }
1545
7.06M
    }
Unexecuted instantiation: <smallvec::SmallVec<_> as core::ops::deref::Deref>::deref
Unexecuted instantiation: <smallvec::SmallVec<[base::wait_context::TriggeredEvent<<devices::serial::Serial>::spawn_input_thread::{closure#0}::Token>; 16]> as core::ops::deref::Deref>::deref
Unexecuted instantiation: <smallvec::SmallVec<[base::wait_context::TriggeredEvent<devices::bat::Token>; 16]> as core::ops::deref::Deref>::deref
Unexecuted instantiation: <smallvec::SmallVec<[base::wait_context::TriggeredEvent<devices::pit::Token>; 16]> as core::ops::deref::Deref>::deref
Unexecuted instantiation: <smallvec::SmallVec<[base::wait_context::TriggeredEvent<devices::virtio::console::worker::Token>; 16]> as core::ops::deref::Deref>::deref
Unexecuted instantiation: <smallvec::SmallVec<[base::wait_context::TriggeredEvent<<devices::vmwdt::Vmwdt>::vmwdt_worker_thread::Token>; 16]> as core::ops::deref::Deref>::deref
Unexecuted instantiation: <smallvec::SmallVec<[base::wait_context::TriggeredEvent<<devices::virtio::p9::Worker>::run::Token>; 16]> as core::ops::deref::Deref>::deref
Unexecuted instantiation: <smallvec::SmallVec<[base::wait_context::TriggeredEvent<<devices::virtio::rng::Worker>::run::Token>; 16]> as core::ops::deref::Deref>::deref
Unexecuted instantiation: <smallvec::SmallVec<[base::wait_context::TriggeredEvent<<devices::virtio::vhost::worker::Worker<_>>::run::Token>; 16]> as core::ops::deref::Deref>::deref
Unexecuted instantiation: <smallvec::SmallVec<[base::wait_context::TriggeredEvent<<devices::pci::coiommu::PinWorker>::run::Token>; 16]> as core::ops::deref::Deref>::deref
Unexecuted instantiation: <smallvec::SmallVec<[base::wait_context::TriggeredEvent<<devices::pci::coiommu::UnpinWorker>::run::Token>; 16]> as core::ops::deref::Deref>::deref
Unexecuted instantiation: <smallvec::SmallVec<[base::wait_context::TriggeredEvent<<devices::pci::vfio_pci::VfioPciWorker>::run::Token>; 16]> as core::ops::deref::Deref>::deref
Unexecuted instantiation: <smallvec::SmallVec<[base::wait_context::TriggeredEvent<<devices::virtio::fs::worker::Worker<_>>::run::Token>; 16]> as core::ops::deref::Deref>::deref
Unexecuted instantiation: <smallvec::SmallVec<[base::wait_context::TriggeredEvent<<devices::virtio::wl::Worker>::run::Token>; 16]> as core::ops::deref::Deref>::deref
Unexecuted instantiation: <smallvec::SmallVec<[base::wait_context::TriggeredEvent<devices::virtcpufreq_v2::vcpufreq_worker_thread::Token>; 16]> as core::ops::deref::Deref>::deref
Unexecuted instantiation: <smallvec::SmallVec<[base::wait_context::TriggeredEvent<devices::acpi::run_worker::Token>; 16]> as core::ops::deref::Deref>::deref
Unexecuted instantiation: <smallvec::SmallVec<[base::wait_context::TriggeredEvent<devices::cmos::run_cmos_worker::Token>; 16]> as core::ops::deref::Deref>::deref
Unexecuted instantiation: <smallvec::SmallVec<[base::wait_context::TriggeredEvent<devices::virtio::console::sys::linux::read_input::Token>; 16]> as core::ops::deref::Deref>::deref
Unexecuted instantiation: <smallvec::SmallVec<[base::wait_context::TriggeredEvent<u32>; 16]> as core::ops::deref::Deref>::deref
Unexecuted instantiation: <smallvec::SmallVec<[base::volatile_memory::VolatileSlice; 16]> as core::ops::deref::Deref>::deref
<smallvec::SmallVec<[cros_async::mem::MemRegion; 2]> as core::ops::deref::Deref>::deref
Line
Count
Source
1540
7.06M
    fn deref(&self) -> &[A::Item] {
1541
        unsafe {
1542
7.06M
            let (ptr, len, _) = self.triple();
1543
7.06M
            slice::from_raw_parts(ptr, len)
1544
        }
1545
7.06M
    }
Unexecuted instantiation: <smallvec::SmallVec<[base::wait_context::TriggeredEvent<metrics::controller::MetricsControllerToken>; 16]> as core::ops::deref::Deref>::deref
Unexecuted instantiation: <smallvec::SmallVec<[base::wait_context::TriggeredEvent<usize>; 16]> as core::ops::deref::Deref>::deref
1546
}
1547
1548
impl<A: Array> ops::DerefMut for SmallVec<A> {
1549
    #[inline]
1550
2.44M
    fn deref_mut(&mut self) -> &mut [A::Item] {
1551
2.44M
        unsafe {
1552
2.44M
            let (ptr, &mut len, _) = self.triple_mut();
1553
2.44M
            slice::from_raw_parts_mut(ptr, len)
1554
2.44M
        }
1555
2.44M
    }
Unexecuted instantiation: <smallvec::SmallVec<_> as core::ops::deref::DerefMut>::deref_mut
Unexecuted instantiation: <smallvec::SmallVec<[base::wait_context::TriggeredEvent<<devices::serial::Serial>::spawn_input_thread::{closure#0}::Token>; 16]> as core::ops::deref::DerefMut>::deref_mut
Unexecuted instantiation: <smallvec::SmallVec<[base::wait_context::TriggeredEvent<devices::bat::Token>; 16]> as core::ops::deref::DerefMut>::deref_mut
Unexecuted instantiation: <smallvec::SmallVec<[base::wait_context::TriggeredEvent<devices::pit::Token>; 16]> as core::ops::deref::DerefMut>::deref_mut
Unexecuted instantiation: <smallvec::SmallVec<[base::wait_context::TriggeredEvent<devices::virtio::console::worker::Token>; 16]> as core::ops::deref::DerefMut>::deref_mut
Unexecuted instantiation: <smallvec::SmallVec<[base::wait_context::TriggeredEvent<<devices::vmwdt::Vmwdt>::vmwdt_worker_thread::Token>; 16]> as core::ops::deref::DerefMut>::deref_mut
Unexecuted instantiation: <smallvec::SmallVec<[base::wait_context::TriggeredEvent<<devices::virtio::p9::Worker>::run::Token>; 16]> as core::ops::deref::DerefMut>::deref_mut
Unexecuted instantiation: <smallvec::SmallVec<[base::wait_context::TriggeredEvent<<devices::virtio::rng::Worker>::run::Token>; 16]> as core::ops::deref::DerefMut>::deref_mut
Unexecuted instantiation: <smallvec::SmallVec<[base::wait_context::TriggeredEvent<<devices::virtio::vhost_user_frontend::worker::Worker>::run::Token>; 16]> as core::ops::deref::DerefMut>::deref_mut
Unexecuted instantiation: <smallvec::SmallVec<[base::wait_context::TriggeredEvent<<devices::virtio::vhost::worker::Worker<_>>::run::Token>; 16]> as core::ops::deref::DerefMut>::deref_mut
Unexecuted instantiation: <smallvec::SmallVec<[base::wait_context::TriggeredEvent<<devices::pci::coiommu::PinWorker>::run::Token>; 16]> as core::ops::deref::DerefMut>::deref_mut
Unexecuted instantiation: <smallvec::SmallVec<[base::wait_context::TriggeredEvent<<devices::pci::coiommu::UnpinWorker>::run::Token>; 16]> as core::ops::deref::DerefMut>::deref_mut
Unexecuted instantiation: <smallvec::SmallVec<[base::wait_context::TriggeredEvent<<devices::pci::vfio_pci::VfioPciWorker>::run::Token>; 16]> as core::ops::deref::DerefMut>::deref_mut
Unexecuted instantiation: <smallvec::SmallVec<[base::wait_context::TriggeredEvent<<devices::virtio::fs::worker::Worker<_>>::run::Token>; 16]> as core::ops::deref::DerefMut>::deref_mut
Unexecuted instantiation: <smallvec::SmallVec<[base::wait_context::TriggeredEvent<<devices::virtio::wl::Worker>::run::Token>; 16]> as core::ops::deref::DerefMut>::deref_mut
Unexecuted instantiation: <smallvec::SmallVec<[base::wait_context::TriggeredEvent<devices::virtcpufreq_v2::vcpufreq_worker_thread::Token>; 16]> as core::ops::deref::DerefMut>::deref_mut
Unexecuted instantiation: <smallvec::SmallVec<[base::wait_context::TriggeredEvent<devices::acpi::run_worker::Token>; 16]> as core::ops::deref::DerefMut>::deref_mut
Unexecuted instantiation: <smallvec::SmallVec<[base::wait_context::TriggeredEvent<devices::cmos::run_cmos_worker::Token>; 16]> as core::ops::deref::DerefMut>::deref_mut
Unexecuted instantiation: <smallvec::SmallVec<[base::wait_context::TriggeredEvent<devices::virtio::interrupt::interrupt_resample_thread::Token>; 16]> as core::ops::deref::DerefMut>::deref_mut
Unexecuted instantiation: <smallvec::SmallVec<[base::wait_context::TriggeredEvent<devices::virtio::console::sys::linux::read_input::Token>; 16]> as core::ops::deref::DerefMut>::deref_mut
Unexecuted instantiation: <smallvec::SmallVec<[base::wait_context::TriggeredEvent<u32>; 16]> as core::ops::deref::DerefMut>::deref_mut
<smallvec::SmallVec<[base::volatile_memory::VolatileSlice; 16]> as core::ops::deref::DerefMut>::deref_mut
Line
Count
Source
1550
654k
    fn deref_mut(&mut self) -> &mut [A::Item] {
1551
654k
        unsafe {
1552
654k
            let (ptr, &mut len, _) = self.triple_mut();
1553
654k
            slice::from_raw_parts_mut(ptr, len)
1554
654k
        }
1555
654k
    }
<smallvec::SmallVec<[cros_async::mem::MemRegion; 2]> as core::ops::deref::DerefMut>::deref_mut
Line
Count
Source
1550
1.78M
    fn deref_mut(&mut self) -> &mut [A::Item] {
1551
1.78M
        unsafe {
1552
1.78M
            let (ptr, &mut len, _) = self.triple_mut();
1553
1.78M
            slice::from_raw_parts_mut(ptr, len)
1554
1.78M
        }
1555
1.78M
    }
Unexecuted instantiation: <smallvec::SmallVec<[base::wait_context::TriggeredEvent<metrics::controller::MetricsControllerToken>; 16]> as core::ops::deref::DerefMut>::deref_mut
Unexecuted instantiation: <smallvec::SmallVec<[base::wait_context::TriggeredEvent<usize>; 16]> as core::ops::deref::DerefMut>::deref_mut
1556
}
1557
1558
impl<A: Array> AsRef<[A::Item]> for SmallVec<A> {
1559
    #[inline]
1560
0
    fn as_ref(&self) -> &[A::Item] {
1561
0
        self
1562
0
    }
1563
}
1564
1565
impl<A: Array> AsMut<[A::Item]> for SmallVec<A> {
1566
    #[inline]
1567
0
    fn as_mut(&mut self) -> &mut [A::Item] {
1568
0
        self
1569
0
    }
1570
}
1571
1572
impl<A: Array> Borrow<[A::Item]> for SmallVec<A> {
1573
    #[inline]
1574
0
    fn borrow(&self) -> &[A::Item] {
1575
0
        self
1576
0
    }
1577
}
1578
1579
impl<A: Array> BorrowMut<[A::Item]> for SmallVec<A> {
1580
    #[inline]
1581
0
    fn borrow_mut(&mut self) -> &mut [A::Item] {
1582
0
        self
1583
0
    }
1584
}
1585
1586
#[cfg(feature = "write")]
1587
#[cfg_attr(docsrs, doc(cfg(feature = "write")))]
1588
impl<A: Array<Item = u8>> io::Write for SmallVec<A> {
1589
    #[inline]
1590
    fn write(&mut self, buf: &[u8]) -> io::Result<usize> {
1591
        self.extend_from_slice(buf);
1592
        Ok(buf.len())
1593
    }
1594
1595
    #[inline]
1596
    fn write_all(&mut self, buf: &[u8]) -> io::Result<()> {
1597
        self.extend_from_slice(buf);
1598
        Ok(())
1599
    }
1600
1601
    #[inline]
1602
    fn flush(&mut self) -> io::Result<()> {
1603
        Ok(())
1604
    }
1605
}
1606
1607
#[cfg(feature = "serde")]
1608
#[cfg_attr(docsrs, doc(cfg(feature = "serde")))]
1609
impl<A: Array> Serialize for SmallVec<A>
1610
where
1611
    A::Item: Serialize,
1612
{
1613
    fn serialize<S: Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
1614
        let mut state = serializer.serialize_seq(Some(self.len()))?;
1615
        for item in self {
1616
            state.serialize_element(&item)?;
1617
        }
1618
        state.end()
1619
    }
1620
}
1621
1622
#[cfg(feature = "serde")]
1623
#[cfg_attr(docsrs, doc(cfg(feature = "serde")))]
1624
impl<'de, A: Array> Deserialize<'de> for SmallVec<A>
1625
where
1626
    A::Item: Deserialize<'de>,
1627
{
1628
    fn deserialize<D: Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
1629
        deserializer.deserialize_seq(SmallVecVisitor {
1630
            phantom: PhantomData,
1631
        })
1632
    }
1633
}
1634
1635
#[cfg(feature = "serde")]
1636
struct SmallVecVisitor<A> {
1637
    phantom: PhantomData<A>,
1638
}
1639
1640
#[cfg(feature = "serde")]
1641
impl<'de, A: Array> Visitor<'de> for SmallVecVisitor<A>
1642
where
1643
    A::Item: Deserialize<'de>,
1644
{
1645
    type Value = SmallVec<A>;
1646
1647
    fn expecting(&self, formatter: &mut fmt::Formatter<'_>) -> fmt::Result {
1648
        formatter.write_str("a sequence")
1649
    }
1650
1651
    fn visit_seq<B>(self, mut seq: B) -> Result<Self::Value, B::Error>
1652
    where
1653
        B: SeqAccess<'de>,
1654
    {
1655
        use serde::de::Error;
1656
        let len = seq.size_hint().unwrap_or(0);
1657
        let mut values = SmallVec::new();
1658
        values.try_reserve(len).map_err(B::Error::custom)?;
1659
1660
        while let Some(value) = seq.next_element()? {
1661
            values.push(value);
1662
        }
1663
1664
        Ok(values)
1665
    }
1666
}
1667
1668
#[cfg(feature = "specialization")]
1669
trait SpecFrom<A: Array, S> {
1670
    fn spec_from(slice: S) -> SmallVec<A>;
1671
}
1672
1673
#[cfg(feature = "specialization")]
1674
mod specialization;
1675
1676
#[cfg(feature = "arbitrary")]
1677
mod arbitrary;
1678
1679
#[cfg(feature = "specialization")]
1680
impl<'a, A: Array> SpecFrom<A, &'a [A::Item]> for SmallVec<A>
1681
where
1682
    A::Item: Copy,
1683
{
1684
    #[inline]
1685
    fn spec_from(slice: &'a [A::Item]) -> SmallVec<A> {
1686
        SmallVec::from_slice(slice)
1687
    }
1688
}
1689
1690
impl<'a, A: Array> From<&'a [A::Item]> for SmallVec<A>
1691
where
1692
    A::Item: Clone,
1693
{
1694
    #[cfg(not(feature = "specialization"))]
1695
    #[inline]
1696
239k
    fn from(slice: &'a [A::Item]) -> SmallVec<A> {
1697
239k
        slice.iter().cloned().collect()
1698
239k
    }
Unexecuted instantiation: <smallvec::SmallVec<_> as core::convert::From<&[<_ as smallvec::Array>::Item]>>::from
<smallvec::SmallVec<[cros_async::mem::MemRegion; 2]> as core::convert::From<&[cros_async::mem::MemRegion]>>::from
Line
Count
Source
1696
239k
    fn from(slice: &'a [A::Item]) -> SmallVec<A> {
1697
239k
        slice.iter().cloned().collect()
1698
239k
    }
1699
1700
    #[cfg(feature = "specialization")]
1701
    #[inline]
1702
    fn from(slice: &'a [A::Item]) -> SmallVec<A> {
1703
        SmallVec::spec_from(slice)
1704
    }
1705
}
1706
1707
impl<A: Array> From<Vec<A::Item>> for SmallVec<A> {
1708
    #[inline]
1709
0
    fn from(vec: Vec<A::Item>) -> SmallVec<A> {
1710
0
        SmallVec::from_vec(vec)
1711
0
    }
1712
}
1713
1714
impl<A: Array> From<A> for SmallVec<A> {
1715
    #[inline]
1716
0
    fn from(array: A) -> SmallVec<A> {
1717
0
        SmallVec::from_buf(array)
1718
0
    }
1719
}
1720
1721
impl<A: Array, I: SliceIndex<[A::Item]>> ops::Index<I> for SmallVec<A> {
1722
    type Output = I::Output;
1723
1724
2.52M
    fn index(&self, index: I) -> &I::Output {
1725
2.52M
        &(**self)[index]
1726
2.52M
    }
Unexecuted instantiation: <smallvec::SmallVec<_> as core::ops::index::Index<_>>::index
Unexecuted instantiation: <smallvec::SmallVec<[base::volatile_memory::VolatileSlice; 16]> as core::ops::index::Index<core::ops::range::RangeFull>>::index
<smallvec::SmallVec<[cros_async::mem::MemRegion; 2]> as core::ops::index::Index<core::ops::range::RangeFrom<usize>>>::index
Line
Count
Source
1724
2.52M
    fn index(&self, index: I) -> &I::Output {
1725
2.52M
        &(**self)[index]
1726
2.52M
    }
1727
}
1728
1729
impl<A: Array, I: SliceIndex<[A::Item]>> ops::IndexMut<I> for SmallVec<A> {
1730
2.44M
    fn index_mut(&mut self, index: I) -> &mut I::Output {
1731
2.44M
        &mut (&mut **self)[index]
1732
2.44M
    }
Unexecuted instantiation: <smallvec::SmallVec<_> as core::ops::index::IndexMut<_>>::index_mut
Unexecuted instantiation: <smallvec::SmallVec<[base::wait_context::TriggeredEvent<<devices::serial::Serial>::spawn_input_thread::{closure#0}::Token>; 16]> as core::ops::index::IndexMut<core::ops::range::RangeFull>>::index_mut
Unexecuted instantiation: <smallvec::SmallVec<[base::wait_context::TriggeredEvent<devices::bat::Token>; 16]> as core::ops::index::IndexMut<core::ops::range::RangeFull>>::index_mut
Unexecuted instantiation: <smallvec::SmallVec<[base::wait_context::TriggeredEvent<devices::pit::Token>; 16]> as core::ops::index::IndexMut<core::ops::range::RangeFull>>::index_mut
Unexecuted instantiation: <smallvec::SmallVec<[base::wait_context::TriggeredEvent<devices::virtio::console::worker::Token>; 16]> as core::ops::index::IndexMut<core::ops::range::RangeFull>>::index_mut
Unexecuted instantiation: <smallvec::SmallVec<[base::wait_context::TriggeredEvent<<devices::vmwdt::Vmwdt>::vmwdt_worker_thread::Token>; 16]> as core::ops::index::IndexMut<core::ops::range::RangeFull>>::index_mut
Unexecuted instantiation: <smallvec::SmallVec<[base::wait_context::TriggeredEvent<<devices::virtio::p9::Worker>::run::Token>; 16]> as core::ops::index::IndexMut<core::ops::range::RangeFull>>::index_mut
Unexecuted instantiation: <smallvec::SmallVec<[base::wait_context::TriggeredEvent<<devices::virtio::rng::Worker>::run::Token>; 16]> as core::ops::index::IndexMut<core::ops::range::RangeFull>>::index_mut
Unexecuted instantiation: <smallvec::SmallVec<[base::wait_context::TriggeredEvent<<devices::virtio::vhost_user_frontend::worker::Worker>::run::Token>; 16]> as core::ops::index::IndexMut<core::ops::range::RangeFull>>::index_mut
Unexecuted instantiation: <smallvec::SmallVec<[base::wait_context::TriggeredEvent<<devices::virtio::vhost::worker::Worker<_>>::run::Token>; 16]> as core::ops::index::IndexMut<core::ops::range::RangeFull>>::index_mut
Unexecuted instantiation: <smallvec::SmallVec<[base::wait_context::TriggeredEvent<<devices::pci::coiommu::PinWorker>::run::Token>; 16]> as core::ops::index::IndexMut<core::ops::range::RangeFull>>::index_mut
Unexecuted instantiation: <smallvec::SmallVec<[base::wait_context::TriggeredEvent<<devices::pci::coiommu::UnpinWorker>::run::Token>; 16]> as core::ops::index::IndexMut<core::ops::range::RangeFull>>::index_mut
Unexecuted instantiation: <smallvec::SmallVec<[base::wait_context::TriggeredEvent<<devices::pci::vfio_pci::VfioPciWorker>::run::Token>; 16]> as core::ops::index::IndexMut<core::ops::range::RangeFull>>::index_mut
Unexecuted instantiation: <smallvec::SmallVec<[base::wait_context::TriggeredEvent<<devices::virtio::fs::worker::Worker<_>>::run::Token>; 16]> as core::ops::index::IndexMut<core::ops::range::RangeFull>>::index_mut
Unexecuted instantiation: <smallvec::SmallVec<[base::wait_context::TriggeredEvent<<devices::virtio::wl::Worker>::run::Token>; 16]> as core::ops::index::IndexMut<core::ops::range::RangeFull>>::index_mut
Unexecuted instantiation: <smallvec::SmallVec<[base::wait_context::TriggeredEvent<devices::virtcpufreq_v2::vcpufreq_worker_thread::Token>; 16]> as core::ops::index::IndexMut<core::ops::range::RangeFull>>::index_mut
Unexecuted instantiation: <smallvec::SmallVec<[base::wait_context::TriggeredEvent<devices::acpi::run_worker::Token>; 16]> as core::ops::index::IndexMut<core::ops::range::RangeFull>>::index_mut
Unexecuted instantiation: <smallvec::SmallVec<[base::wait_context::TriggeredEvent<devices::cmos::run_cmos_worker::Token>; 16]> as core::ops::index::IndexMut<core::ops::range::RangeFull>>::index_mut
Unexecuted instantiation: <smallvec::SmallVec<[base::wait_context::TriggeredEvent<devices::virtio::interrupt::interrupt_resample_thread::Token>; 16]> as core::ops::index::IndexMut<core::ops::range::RangeFull>>::index_mut
Unexecuted instantiation: <smallvec::SmallVec<[base::wait_context::TriggeredEvent<devices::virtio::console::sys::linux::read_input::Token>; 16]> as core::ops::index::IndexMut<core::ops::range::RangeFull>>::index_mut
Unexecuted instantiation: <smallvec::SmallVec<[base::wait_context::TriggeredEvent<u32>; 16]> as core::ops::index::IndexMut<core::ops::range::RangeFull>>::index_mut
<smallvec::SmallVec<[base::volatile_memory::VolatileSlice; 16]> as core::ops::index::IndexMut<core::ops::range::RangeFull>>::index_mut
Line
Count
Source
1730
654k
    fn index_mut(&mut self, index: I) -> &mut I::Output {
1731
654k
        &mut (&mut **self)[index]
1732
654k
    }
<smallvec::SmallVec<[cros_async::mem::MemRegion; 2]> as core::ops::index::IndexMut<core::ops::range::RangeFrom<usize>>>::index_mut
Line
Count
Source
1730
239k
    fn index_mut(&mut self, index: I) -> &mut I::Output {
1731
239k
        &mut (&mut **self)[index]
1732
239k
    }
<smallvec::SmallVec<[cros_async::mem::MemRegion; 2]> as core::ops::index::IndexMut<core::ops::range::RangeFull>>::index_mut
Line
Count
Source
1730
1.54M
    fn index_mut(&mut self, index: I) -> &mut I::Output {
1731
1.54M
        &mut (&mut **self)[index]
1732
1.54M
    }
Unexecuted instantiation: <smallvec::SmallVec<[base::wait_context::TriggeredEvent<metrics::controller::MetricsControllerToken>; 16]> as core::ops::index::IndexMut<core::ops::range::RangeFull>>::index_mut
Unexecuted instantiation: <smallvec::SmallVec<[base::wait_context::TriggeredEvent<usize>; 16]> as core::ops::index::IndexMut<core::ops::range::RangeFull>>::index_mut
1733
}
1734
1735
#[allow(deprecated)]
1736
impl<A: Array> ExtendFromSlice<A::Item> for SmallVec<A>
1737
where
1738
    A::Item: Copy,
1739
{
1740
0
    fn extend_from_slice(&mut self, other: &[A::Item]) {
1741
0
        SmallVec::extend_from_slice(self, other)
1742
0
    }
1743
}
1744
1745
impl<A: Array> FromIterator<A::Item> for SmallVec<A> {
1746
    #[inline]
1747
893k
    fn from_iter<I: IntoIterator<Item = A::Item>>(iterable: I) -> SmallVec<A> {
1748
893k
        let mut v = SmallVec::new();
1749
893k
        v.extend(iterable);
1750
893k
        v
1751
893k
    }
Unexecuted instantiation: <smallvec::SmallVec<_> as core::iter::traits::collect::FromIterator<<_ as smallvec::Array>::Item>>::from_iter::<_>
Unexecuted instantiation: <smallvec::SmallVec<[base::wait_context::TriggeredEvent<<devices::serial::Serial>::spawn_input_thread::{closure#0}::Token>; 16]> as core::iter::traits::collect::FromIterator<base::wait_context::TriggeredEvent<<devices::serial::Serial>::spawn_input_thread::{closure#0}::Token>>>::from_iter::<core::iter::adapters::map::Map<core::slice::iter::Iter<core::mem::maybe_uninit::MaybeUninit<libc::unix::linux_like::epoll_event>>, <base::sys::linux::poll::EventContext<<devices::serial::Serial>::spawn_input_thread::{closure#0}::Token>>::wait_timeout::{closure#1}>>
Unexecuted instantiation: <smallvec::SmallVec<[base::wait_context::TriggeredEvent<devices::bat::Token>; 16]> as core::iter::traits::collect::FromIterator<base::wait_context::TriggeredEvent<devices::bat::Token>>>::from_iter::<core::iter::adapters::map::Map<core::slice::iter::Iter<core::mem::maybe_uninit::MaybeUninit<libc::unix::linux_like::epoll_event>>, <base::sys::linux::poll::EventContext<devices::bat::Token>>::wait_timeout::{closure#1}>>
Unexecuted instantiation: <smallvec::SmallVec<[base::wait_context::TriggeredEvent<devices::pit::Token>; 16]> as core::iter::traits::collect::FromIterator<base::wait_context::TriggeredEvent<devices::pit::Token>>>::from_iter::<core::iter::adapters::map::Map<core::slice::iter::Iter<core::mem::maybe_uninit::MaybeUninit<libc::unix::linux_like::epoll_event>>, <base::sys::linux::poll::EventContext<devices::pit::Token>>::wait_timeout::{closure#1}>>
Unexecuted instantiation: <smallvec::SmallVec<[base::wait_context::TriggeredEvent<devices::virtio::console::worker::Token>; 16]> as core::iter::traits::collect::FromIterator<base::wait_context::TriggeredEvent<devices::virtio::console::worker::Token>>>::from_iter::<core::iter::adapters::map::Map<core::slice::iter::Iter<core::mem::maybe_uninit::MaybeUninit<libc::unix::linux_like::epoll_event>>, <base::sys::linux::poll::EventContext<devices::virtio::console::worker::Token>>::wait_timeout::{closure#1}>>
Unexecuted instantiation: <smallvec::SmallVec<[base::wait_context::TriggeredEvent<<devices::vmwdt::Vmwdt>::vmwdt_worker_thread::Token>; 16]> as core::iter::traits::collect::FromIterator<base::wait_context::TriggeredEvent<<devices::vmwdt::Vmwdt>::vmwdt_worker_thread::Token>>>::from_iter::<core::iter::adapters::map::Map<core::slice::iter::Iter<core::mem::maybe_uninit::MaybeUninit<libc::unix::linux_like::epoll_event>>, <base::sys::linux::poll::EventContext<<devices::vmwdt::Vmwdt>::vmwdt_worker_thread::Token>>::wait_timeout::{closure#1}>>
Unexecuted instantiation: <smallvec::SmallVec<[base::wait_context::TriggeredEvent<<devices::virtio::p9::Worker>::run::Token>; 16]> as core::iter::traits::collect::FromIterator<base::wait_context::TriggeredEvent<<devices::virtio::p9::Worker>::run::Token>>>::from_iter::<core::iter::adapters::map::Map<core::slice::iter::Iter<core::mem::maybe_uninit::MaybeUninit<libc::unix::linux_like::epoll_event>>, <base::sys::linux::poll::EventContext<<devices::virtio::p9::Worker>::run::Token>>::wait_timeout::{closure#1}>>
Unexecuted instantiation: <smallvec::SmallVec<[base::wait_context::TriggeredEvent<<devices::virtio::rng::Worker>::run::Token>; 16]> as core::iter::traits::collect::FromIterator<base::wait_context::TriggeredEvent<<devices::virtio::rng::Worker>::run::Token>>>::from_iter::<core::iter::adapters::map::Map<core::slice::iter::Iter<core::mem::maybe_uninit::MaybeUninit<libc::unix::linux_like::epoll_event>>, <base::sys::linux::poll::EventContext<<devices::virtio::rng::Worker>::run::Token>>::wait_timeout::{closure#1}>>
Unexecuted instantiation: <smallvec::SmallVec<[base::wait_context::TriggeredEvent<<devices::virtio::vhost_user_frontend::worker::Worker>::run::Token>; 16]> as core::iter::traits::collect::FromIterator<base::wait_context::TriggeredEvent<<devices::virtio::vhost_user_frontend::worker::Worker>::run::Token>>>::from_iter::<core::iter::adapters::map::Map<core::slice::iter::Iter<core::mem::maybe_uninit::MaybeUninit<libc::unix::linux_like::epoll_event>>, <base::sys::linux::poll::EventContext<<devices::virtio::vhost_user_frontend::worker::Worker>::run::Token>>::wait_timeout::{closure#1}>>
Unexecuted instantiation: <smallvec::SmallVec<[base::wait_context::TriggeredEvent<<devices::virtio::vhost::worker::Worker<_>>::run::Token>; 16]> as core::iter::traits::collect::FromIterator<base::wait_context::TriggeredEvent<<devices::virtio::vhost::worker::Worker<_>>::run::Token>>>::from_iter::<core::iter::adapters::map::Map<core::slice::iter::Iter<core::mem::maybe_uninit::MaybeUninit<libc::unix::linux_like::epoll_event>>, <base::sys::linux::poll::EventContext<<devices::virtio::vhost::worker::Worker<_>>::run::Token>>::wait_timeout::{closure#1}>>
Unexecuted instantiation: <smallvec::SmallVec<[base::wait_context::TriggeredEvent<<devices::pci::coiommu::PinWorker>::run::Token>; 16]> as core::iter::traits::collect::FromIterator<base::wait_context::TriggeredEvent<<devices::pci::coiommu::PinWorker>::run::Token>>>::from_iter::<core::iter::adapters::map::Map<core::slice::iter::Iter<core::mem::maybe_uninit::MaybeUninit<libc::unix::linux_like::epoll_event>>, <base::sys::linux::poll::EventContext<<devices::pci::coiommu::PinWorker>::run::Token>>::wait_timeout::{closure#1}>>
Unexecuted instantiation: <smallvec::SmallVec<[base::wait_context::TriggeredEvent<<devices::pci::coiommu::UnpinWorker>::run::Token>; 16]> as core::iter::traits::collect::FromIterator<base::wait_context::TriggeredEvent<<devices::pci::coiommu::UnpinWorker>::run::Token>>>::from_iter::<core::iter::adapters::map::Map<core::slice::iter::Iter<core::mem::maybe_uninit::MaybeUninit<libc::unix::linux_like::epoll_event>>, <base::sys::linux::poll::EventContext<<devices::pci::coiommu::UnpinWorker>::run::Token>>::wait_timeout::{closure#1}>>
Unexecuted instantiation: <smallvec::SmallVec<[base::wait_context::TriggeredEvent<<devices::pci::vfio_pci::VfioPciWorker>::run::Token>; 16]> as core::iter::traits::collect::FromIterator<base::wait_context::TriggeredEvent<<devices::pci::vfio_pci::VfioPciWorker>::run::Token>>>::from_iter::<core::iter::adapters::map::Map<core::slice::iter::Iter<core::mem::maybe_uninit::MaybeUninit<libc::unix::linux_like::epoll_event>>, <base::sys::linux::poll::EventContext<<devices::pci::vfio_pci::VfioPciWorker>::run::Token>>::wait_timeout::{closure#1}>>
Unexecuted instantiation: <smallvec::SmallVec<[base::wait_context::TriggeredEvent<<devices::virtio::fs::worker::Worker<_>>::run::Token>; 16]> as core::iter::traits::collect::FromIterator<base::wait_context::TriggeredEvent<<devices::virtio::fs::worker::Worker<_>>::run::Token>>>::from_iter::<core::iter::adapters::map::Map<core::slice::iter::Iter<core::mem::maybe_uninit::MaybeUninit<libc::unix::linux_like::epoll_event>>, <base::sys::linux::poll::EventContext<<devices::virtio::fs::worker::Worker<_>>::run::Token>>::wait_timeout::{closure#1}>>
Unexecuted instantiation: <smallvec::SmallVec<[base::wait_context::TriggeredEvent<<devices::virtio::wl::Worker>::run::Token>; 16]> as core::iter::traits::collect::FromIterator<base::wait_context::TriggeredEvent<<devices::virtio::wl::Worker>::run::Token>>>::from_iter::<core::iter::adapters::map::Map<core::slice::iter::Iter<core::mem::maybe_uninit::MaybeUninit<libc::unix::linux_like::epoll_event>>, <base::sys::linux::poll::EventContext<<devices::virtio::wl::Worker>::run::Token>>::wait_timeout::{closure#1}>>
Unexecuted instantiation: <smallvec::SmallVec<[base::wait_context::TriggeredEvent<devices::virtcpufreq_v2::vcpufreq_worker_thread::Token>; 16]> as core::iter::traits::collect::FromIterator<base::wait_context::TriggeredEvent<devices::virtcpufreq_v2::vcpufreq_worker_thread::Token>>>::from_iter::<core::iter::adapters::map::Map<core::slice::iter::Iter<core::mem::maybe_uninit::MaybeUninit<libc::unix::linux_like::epoll_event>>, <base::sys::linux::poll::EventContext<devices::virtcpufreq_v2::vcpufreq_worker_thread::Token>>::wait_timeout::{closure#1}>>
Unexecuted instantiation: <smallvec::SmallVec<[base::wait_context::TriggeredEvent<devices::acpi::run_worker::Token>; 16]> as core::iter::traits::collect::FromIterator<base::wait_context::TriggeredEvent<devices::acpi::run_worker::Token>>>::from_iter::<core::iter::adapters::map::Map<core::slice::iter::Iter<core::mem::maybe_uninit::MaybeUninit<libc::unix::linux_like::epoll_event>>, <base::sys::linux::poll::EventContext<devices::acpi::run_worker::Token>>::wait_timeout::{closure#1}>>
Unexecuted instantiation: <smallvec::SmallVec<[base::wait_context::TriggeredEvent<devices::cmos::run_cmos_worker::Token>; 16]> as core::iter::traits::collect::FromIterator<base::wait_context::TriggeredEvent<devices::cmos::run_cmos_worker::Token>>>::from_iter::<core::iter::adapters::map::Map<core::slice::iter::Iter<core::mem::maybe_uninit::MaybeUninit<libc::unix::linux_like::epoll_event>>, <base::sys::linux::poll::EventContext<devices::cmos::run_cmos_worker::Token>>::wait_timeout::{closure#1}>>
Unexecuted instantiation: <smallvec::SmallVec<[base::wait_context::TriggeredEvent<devices::virtio::interrupt::interrupt_resample_thread::Token>; 16]> as core::iter::traits::collect::FromIterator<base::wait_context::TriggeredEvent<devices::virtio::interrupt::interrupt_resample_thread::Token>>>::from_iter::<core::iter::adapters::map::Map<core::slice::iter::Iter<core::mem::maybe_uninit::MaybeUninit<libc::unix::linux_like::epoll_event>>, <base::sys::linux::poll::EventContext<devices::virtio::interrupt::interrupt_resample_thread::Token>>::wait_timeout::{closure#1}>>
Unexecuted instantiation: <smallvec::SmallVec<[base::wait_context::TriggeredEvent<devices::virtio::console::sys::linux::read_input::Token>; 16]> as core::iter::traits::collect::FromIterator<base::wait_context::TriggeredEvent<devices::virtio::console::sys::linux::read_input::Token>>>::from_iter::<core::iter::adapters::map::Map<core::slice::iter::Iter<core::mem::maybe_uninit::MaybeUninit<libc::unix::linux_like::epoll_event>>, <base::sys::linux::poll::EventContext<devices::virtio::console::sys::linux::read_input::Token>>::wait_timeout::{closure#1}>>
Unexecuted instantiation: <smallvec::SmallVec<[base::wait_context::TriggeredEvent<u32>; 16]> as core::iter::traits::collect::FromIterator<base::wait_context::TriggeredEvent<u32>>>::from_iter::<core::iter::adapters::map::Map<core::slice::iter::Iter<core::mem::maybe_uninit::MaybeUninit<libc::unix::linux_like::epoll_event>>, <base::sys::linux::poll::EventContext<u32>>::wait_timeout::{closure#1}>>
<smallvec::SmallVec<[base::volatile_memory::VolatileSlice; 16]> as core::iter::traits::collect::FromIterator<base::volatile_memory::VolatileSlice>>::from_iter::<core::iter::adapters::filter_map::FilterMap<cros_async::mem::MemRegionIter, <devices::virtio::descriptor_utils::DescriptorChainRegions>::get_remaining::{closure#0}>>
Line
Count
Source
1747
654k
    fn from_iter<I: IntoIterator<Item = A::Item>>(iterable: I) -> SmallVec<A> {
1748
654k
        let mut v = SmallVec::new();
1749
654k
        v.extend(iterable);
1750
654k
        v
1751
654k
    }
Unexecuted instantiation: <smallvec::SmallVec<[base::volatile_memory::VolatileSlice; 16]> as core::iter::traits::collect::FromIterator<base::volatile_memory::VolatileSlice>>::from_iter::<core::iter::adapters::filter_map::FilterMap<cros_async::mem::MemRegionIter, <devices::virtio::descriptor_utils::DescriptorChainRegions>::get_remaining_with_count::{closure#0}>>
<smallvec::SmallVec<[cros_async::mem::MemRegion; 2]> as core::iter::traits::collect::FromIterator<cros_async::mem::MemRegion>>::from_iter::<core::iter::adapters::cloned::Cloned<core::slice::iter::Iter<cros_async::mem::MemRegion>>>
Line
Count
Source
1747
239k
    fn from_iter<I: IntoIterator<Item = A::Item>>(iterable: I) -> SmallVec<A> {
1748
239k
        let mut v = SmallVec::new();
1749
239k
        v.extend(iterable);
1750
239k
        v
1751
239k
    }
Unexecuted instantiation: <smallvec::SmallVec<[base::wait_context::TriggeredEvent<metrics::controller::MetricsControllerToken>; 16]> as core::iter::traits::collect::FromIterator<base::wait_context::TriggeredEvent<metrics::controller::MetricsControllerToken>>>::from_iter::<core::iter::adapters::map::Map<core::slice::iter::Iter<core::mem::maybe_uninit::MaybeUninit<libc::unix::linux_like::epoll_event>>, <base::sys::linux::poll::EventContext<metrics::controller::MetricsControllerToken>>::wait_timeout::{closure#1}>>
Unexecuted instantiation: <smallvec::SmallVec<[base::wait_context::TriggeredEvent<usize>; 16]> as core::iter::traits::collect::FromIterator<base::wait_context::TriggeredEvent<usize>>>::from_iter::<core::iter::adapters::map::Map<core::slice::iter::Iter<core::mem::maybe_uninit::MaybeUninit<libc::unix::linux_like::epoll_event>>, <base::sys::linux::poll::EventContext<usize>>::wait_timeout::{closure#1}>>
1752
}
1753
1754
impl<A: Array> Extend<A::Item> for SmallVec<A> {
1755
893k
    fn extend<I: IntoIterator<Item = A::Item>>(&mut self, iterable: I) {
1756
893k
        let mut iter = iterable.into_iter();
1757
893k
        let (lower_size_bound, _) = iter.size_hint();
1758
893k
        self.reserve(lower_size_bound);
1759
1760
        unsafe {
1761
893k
            let (ptr, len_ptr, cap) = self.triple_mut();
1762
893k
            let mut len = SetLenOnDrop::new(len_ptr);
1763
2.33M
            while len.get() < cap {
1764
2.32M
                if let Some(out) = iter.next() {
1765
1.43M
                    ptr::write(ptr.add(len.get()), out);
1766
1.43M
                    len.increment_len(1);
1767
1.43M
                } else {
1768
889k
                    return;
1769
                }
1770
            }
1771
        }
1772
1773
3.91k
        for elem in iter {
1774
0
            self.push(elem);
1775
0
        }
1776
893k
    }
Unexecuted instantiation: <smallvec::SmallVec<_> as core::iter::traits::collect::Extend<<_ as smallvec::Array>::Item>>::extend::<_>
Unexecuted instantiation: <smallvec::SmallVec<[base::wait_context::TriggeredEvent<<devices::serial::Serial>::spawn_input_thread::{closure#0}::Token>; 16]> as core::iter::traits::collect::Extend<base::wait_context::TriggeredEvent<<devices::serial::Serial>::spawn_input_thread::{closure#0}::Token>>>::extend::<core::iter::adapters::map::Map<core::slice::iter::Iter<core::mem::maybe_uninit::MaybeUninit<libc::unix::linux_like::epoll_event>>, <base::sys::linux::poll::EventContext<<devices::serial::Serial>::spawn_input_thread::{closure#0}::Token>>::wait_timeout::{closure#1}>>
Unexecuted instantiation: <smallvec::SmallVec<[base::wait_context::TriggeredEvent<devices::bat::Token>; 16]> as core::iter::traits::collect::Extend<base::wait_context::TriggeredEvent<devices::bat::Token>>>::extend::<core::iter::adapters::map::Map<core::slice::iter::Iter<core::mem::maybe_uninit::MaybeUninit<libc::unix::linux_like::epoll_event>>, <base::sys::linux::poll::EventContext<devices::bat::Token>>::wait_timeout::{closure#1}>>
Unexecuted instantiation: <smallvec::SmallVec<[base::wait_context::TriggeredEvent<devices::pit::Token>; 16]> as core::iter::traits::collect::Extend<base::wait_context::TriggeredEvent<devices::pit::Token>>>::extend::<core::iter::adapters::map::Map<core::slice::iter::Iter<core::mem::maybe_uninit::MaybeUninit<libc::unix::linux_like::epoll_event>>, <base::sys::linux::poll::EventContext<devices::pit::Token>>::wait_timeout::{closure#1}>>
Unexecuted instantiation: <smallvec::SmallVec<[base::wait_context::TriggeredEvent<devices::virtio::console::worker::Token>; 16]> as core::iter::traits::collect::Extend<base::wait_context::TriggeredEvent<devices::virtio::console::worker::Token>>>::extend::<core::iter::adapters::map::Map<core::slice::iter::Iter<core::mem::maybe_uninit::MaybeUninit<libc::unix::linux_like::epoll_event>>, <base::sys::linux::poll::EventContext<devices::virtio::console::worker::Token>>::wait_timeout::{closure#1}>>
Unexecuted instantiation: <smallvec::SmallVec<[base::wait_context::TriggeredEvent<<devices::vmwdt::Vmwdt>::vmwdt_worker_thread::Token>; 16]> as core::iter::traits::collect::Extend<base::wait_context::TriggeredEvent<<devices::vmwdt::Vmwdt>::vmwdt_worker_thread::Token>>>::extend::<core::iter::adapters::map::Map<core::slice::iter::Iter<core::mem::maybe_uninit::MaybeUninit<libc::unix::linux_like::epoll_event>>, <base::sys::linux::poll::EventContext<<devices::vmwdt::Vmwdt>::vmwdt_worker_thread::Token>>::wait_timeout::{closure#1}>>
Unexecuted instantiation: <smallvec::SmallVec<[base::wait_context::TriggeredEvent<<devices::virtio::p9::Worker>::run::Token>; 16]> as core::iter::traits::collect::Extend<base::wait_context::TriggeredEvent<<devices::virtio::p9::Worker>::run::Token>>>::extend::<core::iter::adapters::map::Map<core::slice::iter::Iter<core::mem::maybe_uninit::MaybeUninit<libc::unix::linux_like::epoll_event>>, <base::sys::linux::poll::EventContext<<devices::virtio::p9::Worker>::run::Token>>::wait_timeout::{closure#1}>>
Unexecuted instantiation: <smallvec::SmallVec<[base::wait_context::TriggeredEvent<<devices::virtio::rng::Worker>::run::Token>; 16]> as core::iter::traits::collect::Extend<base::wait_context::TriggeredEvent<<devices::virtio::rng::Worker>::run::Token>>>::extend::<core::iter::adapters::map::Map<core::slice::iter::Iter<core::mem::maybe_uninit::MaybeUninit<libc::unix::linux_like::epoll_event>>, <base::sys::linux::poll::EventContext<<devices::virtio::rng::Worker>::run::Token>>::wait_timeout::{closure#1}>>
Unexecuted instantiation: <smallvec::SmallVec<[base::wait_context::TriggeredEvent<<devices::virtio::vhost_user_frontend::worker::Worker>::run::Token>; 16]> as core::iter::traits::collect::Extend<base::wait_context::TriggeredEvent<<devices::virtio::vhost_user_frontend::worker::Worker>::run::Token>>>::extend::<core::iter::adapters::map::Map<core::slice::iter::Iter<core::mem::maybe_uninit::MaybeUninit<libc::unix::linux_like::epoll_event>>, <base::sys::linux::poll::EventContext<<devices::virtio::vhost_user_frontend::worker::Worker>::run::Token>>::wait_timeout::{closure#1}>>
Unexecuted instantiation: <smallvec::SmallVec<[base::wait_context::TriggeredEvent<<devices::virtio::vhost::worker::Worker<_>>::run::Token>; 16]> as core::iter::traits::collect::Extend<base::wait_context::TriggeredEvent<<devices::virtio::vhost::worker::Worker<_>>::run::Token>>>::extend::<core::iter::adapters::map::Map<core::slice::iter::Iter<core::mem::maybe_uninit::MaybeUninit<libc::unix::linux_like::epoll_event>>, <base::sys::linux::poll::EventContext<<devices::virtio::vhost::worker::Worker<_>>::run::Token>>::wait_timeout::{closure#1}>>
Unexecuted instantiation: <smallvec::SmallVec<[base::wait_context::TriggeredEvent<<devices::pci::coiommu::PinWorker>::run::Token>; 16]> as core::iter::traits::collect::Extend<base::wait_context::TriggeredEvent<<devices::pci::coiommu::PinWorker>::run::Token>>>::extend::<core::iter::adapters::map::Map<core::slice::iter::Iter<core::mem::maybe_uninit::MaybeUninit<libc::unix::linux_like::epoll_event>>, <base::sys::linux::poll::EventContext<<devices::pci::coiommu::PinWorker>::run::Token>>::wait_timeout::{closure#1}>>
Unexecuted instantiation: <smallvec::SmallVec<[base::wait_context::TriggeredEvent<<devices::pci::coiommu::UnpinWorker>::run::Token>; 16]> as core::iter::traits::collect::Extend<base::wait_context::TriggeredEvent<<devices::pci::coiommu::UnpinWorker>::run::Token>>>::extend::<core::iter::adapters::map::Map<core::slice::iter::Iter<core::mem::maybe_uninit::MaybeUninit<libc::unix::linux_like::epoll_event>>, <base::sys::linux::poll::EventContext<<devices::pci::coiommu::UnpinWorker>::run::Token>>::wait_timeout::{closure#1}>>
Unexecuted instantiation: <smallvec::SmallVec<[base::wait_context::TriggeredEvent<<devices::pci::vfio_pci::VfioPciWorker>::run::Token>; 16]> as core::iter::traits::collect::Extend<base::wait_context::TriggeredEvent<<devices::pci::vfio_pci::VfioPciWorker>::run::Token>>>::extend::<core::iter::adapters::map::Map<core::slice::iter::Iter<core::mem::maybe_uninit::MaybeUninit<libc::unix::linux_like::epoll_event>>, <base::sys::linux::poll::EventContext<<devices::pci::vfio_pci::VfioPciWorker>::run::Token>>::wait_timeout::{closure#1}>>
Unexecuted instantiation: <smallvec::SmallVec<[base::wait_context::TriggeredEvent<<devices::virtio::fs::worker::Worker<_>>::run::Token>; 16]> as core::iter::traits::collect::Extend<base::wait_context::TriggeredEvent<<devices::virtio::fs::worker::Worker<_>>::run::Token>>>::extend::<core::iter::adapters::map::Map<core::slice::iter::Iter<core::mem::maybe_uninit::MaybeUninit<libc::unix::linux_like::epoll_event>>, <base::sys::linux::poll::EventContext<<devices::virtio::fs::worker::Worker<_>>::run::Token>>::wait_timeout::{closure#1}>>
Unexecuted instantiation: <smallvec::SmallVec<[base::wait_context::TriggeredEvent<<devices::virtio::wl::Worker>::run::Token>; 16]> as core::iter::traits::collect::Extend<base::wait_context::TriggeredEvent<<devices::virtio::wl::Worker>::run::Token>>>::extend::<core::iter::adapters::map::Map<core::slice::iter::Iter<core::mem::maybe_uninit::MaybeUninit<libc::unix::linux_like::epoll_event>>, <base::sys::linux::poll::EventContext<<devices::virtio::wl::Worker>::run::Token>>::wait_timeout::{closure#1}>>
Unexecuted instantiation: <smallvec::SmallVec<[base::wait_context::TriggeredEvent<devices::virtcpufreq_v2::vcpufreq_worker_thread::Token>; 16]> as core::iter::traits::collect::Extend<base::wait_context::TriggeredEvent<devices::virtcpufreq_v2::vcpufreq_worker_thread::Token>>>::extend::<core::iter::adapters::map::Map<core::slice::iter::Iter<core::mem::maybe_uninit::MaybeUninit<libc::unix::linux_like::epoll_event>>, <base::sys::linux::poll::EventContext<devices::virtcpufreq_v2::vcpufreq_worker_thread::Token>>::wait_timeout::{closure#1}>>
Unexecuted instantiation: <smallvec::SmallVec<[base::wait_context::TriggeredEvent<devices::acpi::run_worker::Token>; 16]> as core::iter::traits::collect::Extend<base::wait_context::TriggeredEvent<devices::acpi::run_worker::Token>>>::extend::<core::iter::adapters::map::Map<core::slice::iter::Iter<core::mem::maybe_uninit::MaybeUninit<libc::unix::linux_like::epoll_event>>, <base::sys::linux::poll::EventContext<devices::acpi::run_worker::Token>>::wait_timeout::{closure#1}>>
Unexecuted instantiation: <smallvec::SmallVec<[base::wait_context::TriggeredEvent<devices::cmos::run_cmos_worker::Token>; 16]> as core::iter::traits::collect::Extend<base::wait_context::TriggeredEvent<devices::cmos::run_cmos_worker::Token>>>::extend::<core::iter::adapters::map::Map<core::slice::iter::Iter<core::mem::maybe_uninit::MaybeUninit<libc::unix::linux_like::epoll_event>>, <base::sys::linux::poll::EventContext<devices::cmos::run_cmos_worker::Token>>::wait_timeout::{closure#1}>>
Unexecuted instantiation: <smallvec::SmallVec<[base::wait_context::TriggeredEvent<devices::virtio::interrupt::interrupt_resample_thread::Token>; 16]> as core::iter::traits::collect::Extend<base::wait_context::TriggeredEvent<devices::virtio::interrupt::interrupt_resample_thread::Token>>>::extend::<core::iter::adapters::map::Map<core::slice::iter::Iter<core::mem::maybe_uninit::MaybeUninit<libc::unix::linux_like::epoll_event>>, <base::sys::linux::poll::EventContext<devices::virtio::interrupt::interrupt_resample_thread::Token>>::wait_timeout::{closure#1}>>
Unexecuted instantiation: <smallvec::SmallVec<[base::wait_context::TriggeredEvent<devices::virtio::console::sys::linux::read_input::Token>; 16]> as core::iter::traits::collect::Extend<base::wait_context::TriggeredEvent<devices::virtio::console::sys::linux::read_input::Token>>>::extend::<core::iter::adapters::map::Map<core::slice::iter::Iter<core::mem::maybe_uninit::MaybeUninit<libc::unix::linux_like::epoll_event>>, <base::sys::linux::poll::EventContext<devices::virtio::console::sys::linux::read_input::Token>>::wait_timeout::{closure#1}>>
Unexecuted instantiation: <smallvec::SmallVec<[base::wait_context::TriggeredEvent<u32>; 16]> as core::iter::traits::collect::Extend<base::wait_context::TriggeredEvent<u32>>>::extend::<core::iter::adapters::map::Map<core::slice::iter::Iter<core::mem::maybe_uninit::MaybeUninit<libc::unix::linux_like::epoll_event>>, <base::sys::linux::poll::EventContext<u32>>::wait_timeout::{closure#1}>>
<smallvec::SmallVec<[base::volatile_memory::VolatileSlice; 16]> as core::iter::traits::collect::Extend<base::volatile_memory::VolatileSlice>>::extend::<core::iter::adapters::filter_map::FilterMap<cros_async::mem::MemRegionIter, <devices::virtio::descriptor_utils::DescriptorChainRegions>::get_remaining::{closure#0}>>
Line
Count
Source
1755
654k
    fn extend<I: IntoIterator<Item = A::Item>>(&mut self, iterable: I) {
1756
654k
        let mut iter = iterable.into_iter();
1757
654k
        let (lower_size_bound, _) = iter.size_hint();
1758
654k
        self.reserve(lower_size_bound);
1759
1760
        unsafe {
1761
654k
            let (ptr, len_ptr, cap) = self.triple_mut();
1762
654k
            let mut len = SetLenOnDrop::new(len_ptr);
1763
1.84M
            while len.get() < cap {
1764
1.84M
                if let Some(out) = iter.next() {
1765
1.19M
                    ptr::write(ptr.add(len.get()), out);
1766
1.19M
                    len.increment_len(1);
1767
1.19M
                } else {
1768
654k
                    return;
1769
                }
1770
            }
1771
        }
1772
1773
0
        for elem in iter {
1774
0
            self.push(elem);
1775
0
        }
1776
654k
    }
Unexecuted instantiation: <smallvec::SmallVec<[base::volatile_memory::VolatileSlice; 16]> as core::iter::traits::collect::Extend<base::volatile_memory::VolatileSlice>>::extend::<core::iter::adapters::filter_map::FilterMap<cros_async::mem::MemRegionIter, <devices::virtio::descriptor_utils::DescriptorChainRegions>::get_remaining_with_count::{closure#0}>>
<smallvec::SmallVec<[cros_async::mem::MemRegion; 2]> as core::iter::traits::collect::Extend<cros_async::mem::MemRegion>>::extend::<core::iter::adapters::cloned::Cloned<core::slice::iter::Iter<cros_async::mem::MemRegion>>>
Line
Count
Source
1755
239k
    fn extend<I: IntoIterator<Item = A::Item>>(&mut self, iterable: I) {
1756
239k
        let mut iter = iterable.into_iter();
1757
239k
        let (lower_size_bound, _) = iter.size_hint();
1758
239k
        self.reserve(lower_size_bound);
1759
1760
        unsafe {
1761
239k
            let (ptr, len_ptr, cap) = self.triple_mut();
1762
239k
            let mut len = SetLenOnDrop::new(len_ptr);
1763
488k
            while len.get() < cap {
1764
484k
                if let Some(out) = iter.next() {
1765
249k
                    ptr::write(ptr.add(len.get()), out);
1766
249k
                    len.increment_len(1);
1767
249k
                } else {
1768
235k
                    return;
1769
                }
1770
            }
1771
        }
1772
1773
3.91k
        for elem in iter {
1774
0
            self.push(elem);
1775
0
        }
1776
239k
    }
Unexecuted instantiation: <smallvec::SmallVec<[base::wait_context::TriggeredEvent<metrics::controller::MetricsControllerToken>; 16]> as core::iter::traits::collect::Extend<base::wait_context::TriggeredEvent<metrics::controller::MetricsControllerToken>>>::extend::<core::iter::adapters::map::Map<core::slice::iter::Iter<core::mem::maybe_uninit::MaybeUninit<libc::unix::linux_like::epoll_event>>, <base::sys::linux::poll::EventContext<metrics::controller::MetricsControllerToken>>::wait_timeout::{closure#1}>>
Unexecuted instantiation: <smallvec::SmallVec<[base::wait_context::TriggeredEvent<usize>; 16]> as core::iter::traits::collect::Extend<base::wait_context::TriggeredEvent<usize>>>::extend::<core::iter::adapters::map::Map<core::slice::iter::Iter<core::mem::maybe_uninit::MaybeUninit<libc::unix::linux_like::epoll_event>>, <base::sys::linux::poll::EventContext<usize>>::wait_timeout::{closure#1}>>
1777
}
1778
1779
impl<A: Array> fmt::Debug for SmallVec<A>
1780
where
1781
    A::Item: fmt::Debug,
1782
{
1783
0
    fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
1784
0
        f.debug_list().entries(self.iter()).finish()
1785
0
    }
1786
}
1787
1788
impl<A: Array> Default for SmallVec<A> {
1789
    #[inline]
1790
0
    fn default() -> SmallVec<A> {
1791
0
        SmallVec::new()
1792
0
    }
1793
}
1794
1795
#[cfg(feature = "may_dangle")]
1796
unsafe impl<#[may_dangle] A: Array> Drop for SmallVec<A> {
1797
    fn drop(&mut self) {
1798
        unsafe {
1799
            if self.spilled() {
1800
                let (ptr, len) = self.data.heap();
1801
                Vec::from_raw_parts(ptr, len, self.capacity);
1802
            } else {
1803
                ptr::drop_in_place(&mut self[..]);
1804
            }
1805
        }
1806
    }
1807
}
1808
1809
#[cfg(not(feature = "may_dangle"))]
1810
impl<A: Array> Drop for SmallVec<A> {
1811
2.43M
    fn drop(&mut self) {
1812
        unsafe {
1813
2.43M
            if self.spilled() {
1814
235k
                let (ptr, len) = self.data.heap();
1815
235k
                Vec::from_raw_parts(ptr, len, self.capacity);
1816
2.20M
            } else {
1817
2.20M
                ptr::drop_in_place(&mut self[..]);
1818
2.20M
            }
1819
        }
1820
2.43M
    }
Unexecuted instantiation: <smallvec::SmallVec<_> as core::ops::drop::Drop>::drop
Unexecuted instantiation: <smallvec::SmallVec<[base::wait_context::TriggeredEvent<<devices::serial::Serial>::spawn_input_thread::{closure#0}::Token>; 16]> as core::ops::drop::Drop>::drop
Unexecuted instantiation: <smallvec::SmallVec<[base::wait_context::TriggeredEvent<devices::bat::Token>; 16]> as core::ops::drop::Drop>::drop
Unexecuted instantiation: <smallvec::SmallVec<[base::wait_context::TriggeredEvent<devices::pit::Token>; 16]> as core::ops::drop::Drop>::drop
Unexecuted instantiation: <smallvec::SmallVec<[base::wait_context::TriggeredEvent<devices::virtio::console::worker::Token>; 16]> as core::ops::drop::Drop>::drop
Unexecuted instantiation: <smallvec::SmallVec<[base::wait_context::TriggeredEvent<<devices::vmwdt::Vmwdt>::vmwdt_worker_thread::Token>; 16]> as core::ops::drop::Drop>::drop
Unexecuted instantiation: <smallvec::SmallVec<[base::wait_context::TriggeredEvent<<devices::virtio::p9::Worker>::run::Token>; 16]> as core::ops::drop::Drop>::drop
Unexecuted instantiation: <smallvec::SmallVec<[base::wait_context::TriggeredEvent<<devices::virtio::rng::Worker>::run::Token>; 16]> as core::ops::drop::Drop>::drop
Unexecuted instantiation: <smallvec::SmallVec<[base::wait_context::TriggeredEvent<<devices::virtio::vhost_user_frontend::worker::Worker>::run::Token>; 16]> as core::ops::drop::Drop>::drop
Unexecuted instantiation: <smallvec::SmallVec<[base::wait_context::TriggeredEvent<<devices::virtio::vhost::worker::Worker<_>>::run::Token>; 16]> as core::ops::drop::Drop>::drop
Unexecuted instantiation: <smallvec::SmallVec<[base::wait_context::TriggeredEvent<<devices::pci::coiommu::PinWorker>::run::Token>; 16]> as core::ops::drop::Drop>::drop
Unexecuted instantiation: <smallvec::SmallVec<[base::wait_context::TriggeredEvent<<devices::pci::coiommu::UnpinWorker>::run::Token>; 16]> as core::ops::drop::Drop>::drop
Unexecuted instantiation: <smallvec::SmallVec<[base::wait_context::TriggeredEvent<<devices::pci::vfio_pci::VfioPciWorker>::run::Token>; 16]> as core::ops::drop::Drop>::drop
Unexecuted instantiation: <smallvec::SmallVec<[base::wait_context::TriggeredEvent<<devices::virtio::fs::worker::Worker<_>>::run::Token>; 16]> as core::ops::drop::Drop>::drop
Unexecuted instantiation: <smallvec::SmallVec<[base::wait_context::TriggeredEvent<<devices::virtio::wl::Worker>::run::Token>; 16]> as core::ops::drop::Drop>::drop
Unexecuted instantiation: <smallvec::SmallVec<[base::wait_context::TriggeredEvent<devices::virtcpufreq_v2::vcpufreq_worker_thread::Token>; 16]> as core::ops::drop::Drop>::drop
Unexecuted instantiation: <smallvec::SmallVec<[base::wait_context::TriggeredEvent<devices::acpi::run_worker::Token>; 16]> as core::ops::drop::Drop>::drop
Unexecuted instantiation: <smallvec::SmallVec<[base::wait_context::TriggeredEvent<devices::cmos::run_cmos_worker::Token>; 16]> as core::ops::drop::Drop>::drop
Unexecuted instantiation: <smallvec::SmallVec<[base::wait_context::TriggeredEvent<devices::virtio::interrupt::interrupt_resample_thread::Token>; 16]> as core::ops::drop::Drop>::drop
Unexecuted instantiation: <smallvec::SmallVec<[base::wait_context::TriggeredEvent<devices::virtio::console::sys::linux::read_input::Token>; 16]> as core::ops::drop::Drop>::drop
Unexecuted instantiation: <smallvec::SmallVec<[base::wait_context::TriggeredEvent<u32>; 16]> as core::ops::drop::Drop>::drop
<smallvec::SmallVec<[base::volatile_memory::VolatileSlice; 16]> as core::ops::drop::Drop>::drop
Line
Count
Source
1811
654k
    fn drop(&mut self) {
1812
        unsafe {
1813
654k
            if self.spilled() {
1814
0
                let (ptr, len) = self.data.heap();
1815
0
                Vec::from_raw_parts(ptr, len, self.capacity);
1816
654k
            } else {
1817
654k
                ptr::drop_in_place(&mut self[..]);
1818
654k
            }
1819
        }
1820
654k
    }
<smallvec::SmallVec<[cros_async::mem::MemRegion; 2]> as core::ops::drop::Drop>::drop
Line
Count
Source
1811
1.78M
    fn drop(&mut self) {
1812
        unsafe {
1813
1.78M
            if self.spilled() {
1814
235k
                let (ptr, len) = self.data.heap();
1815
235k
                Vec::from_raw_parts(ptr, len, self.capacity);
1816
1.54M
            } else {
1817
1.54M
                ptr::drop_in_place(&mut self[..]);
1818
1.54M
            }
1819
        }
1820
1.78M
    }
Unexecuted instantiation: <smallvec::SmallVec<[base::wait_context::TriggeredEvent<metrics::controller::MetricsControllerToken>; 16]> as core::ops::drop::Drop>::drop
Unexecuted instantiation: <smallvec::SmallVec<[base::wait_context::TriggeredEvent<usize>; 16]> as core::ops::drop::Drop>::drop
1821
}
1822
1823
impl<A: Array> Clone for SmallVec<A>
1824
where
1825
    A::Item: Clone,
1826
{
1827
    #[inline]
1828
239k
    fn clone(&self) -> SmallVec<A> {
1829
239k
        SmallVec::from(self.as_slice())
1830
239k
    }
Unexecuted instantiation: <smallvec::SmallVec<_> as core::clone::Clone>::clone
<smallvec::SmallVec<[cros_async::mem::MemRegion; 2]> as core::clone::Clone>::clone
Line
Count
Source
1828
239k
    fn clone(&self) -> SmallVec<A> {
1829
239k
        SmallVec::from(self.as_slice())
1830
239k
    }
1831
1832
0
    fn clone_from(&mut self, source: &Self) {
1833
        // Inspired from `impl Clone for Vec`.
1834
1835
        // drop anything that will not be overwritten
1836
0
        self.truncate(source.len());
1837
1838
        // self.len <= other.len due to the truncate above, so the
1839
        // slices here are always in-bounds.
1840
0
        let (init, tail) = source.split_at(self.len());
1841
1842
        // reuse the contained values' allocations/resources.
1843
0
        self.clone_from_slice(init);
1844
0
        self.extend(tail.iter().cloned());
1845
0
    }
1846
}
1847
1848
impl<A: Array, B: Array> PartialEq<SmallVec<B>> for SmallVec<A>
1849
where
1850
    A::Item: PartialEq<B::Item>,
1851
{
1852
    #[inline]
1853
0
    fn eq(&self, other: &SmallVec<B>) -> bool {
1854
0
        self[..] == other[..]
1855
0
    }
1856
}
1857
1858
impl<A: Array> Eq for SmallVec<A> where A::Item: Eq {}
1859
1860
impl<A: Array> PartialOrd for SmallVec<A>
1861
where
1862
    A::Item: PartialOrd,
1863
{
1864
    #[inline]
1865
0
    fn partial_cmp(&self, other: &SmallVec<A>) -> Option<cmp::Ordering> {
1866
0
        PartialOrd::partial_cmp(&**self, &**other)
1867
0
    }
1868
}
1869
1870
impl<A: Array> Ord for SmallVec<A>
1871
where
1872
    A::Item: Ord,
1873
{
1874
    #[inline]
1875
0
    fn cmp(&self, other: &SmallVec<A>) -> cmp::Ordering {
1876
0
        Ord::cmp(&**self, &**other)
1877
0
    }
1878
}
1879
1880
impl<A: Array> Hash for SmallVec<A>
1881
where
1882
    A::Item: Hash,
1883
{
1884
0
    fn hash<H: Hasher>(&self, state: &mut H) {
1885
0
        (**self).hash(state)
1886
0
    }
1887
}
1888
1889
unsafe impl<A: Array> Send for SmallVec<A> where A::Item: Send {}
1890
1891
/// An iterator that consumes a `SmallVec` and yields its items by value.
1892
///
1893
/// Returned from [`SmallVec::into_iter`][1].
1894
///
1895
/// [1]: struct.SmallVec.html#method.into_iter
1896
pub struct IntoIter<A: Array> {
1897
    data: SmallVec<A>,
1898
    current: usize,
1899
    end: usize,
1900
}
1901
1902
impl<A: Array> fmt::Debug for IntoIter<A>
1903
where
1904
    A::Item: fmt::Debug,
1905
{
1906
0
    fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
1907
0
        f.debug_tuple("IntoIter").field(&self.as_slice()).finish()
1908
0
    }
1909
}
1910
1911
impl<A: Array + Clone> Clone for IntoIter<A>
1912
where
1913
    A::Item: Clone,
1914
{
1915
0
    fn clone(&self) -> IntoIter<A> {
1916
0
        SmallVec::from(self.as_slice()).into_iter()
1917
0
    }
1918
}
1919
1920
impl<A: Array> Drop for IntoIter<A> {
1921
654k
    fn drop(&mut self) {
1922
654k
        for _ in self {}
1923
654k
    }
Unexecuted instantiation: <smallvec::IntoIter<_> as core::ops::drop::Drop>::drop
Unexecuted instantiation: <smallvec::IntoIter<[base::wait_context::TriggeredEvent<<devices::virtio::vhost_user_frontend::worker::Worker>::run::Token>; 16]> as core::ops::drop::Drop>::drop
Unexecuted instantiation: <smallvec::IntoIter<[base::wait_context::TriggeredEvent<devices::virtio::interrupt::interrupt_resample_thread::Token>; 16]> as core::ops::drop::Drop>::drop
<smallvec::IntoIter<[base::volatile_memory::VolatileSlice; 16]> as core::ops::drop::Drop>::drop
Line
Count
Source
1921
654k
    fn drop(&mut self) {
1922
654k
        for _ in self {}
1923
654k
    }
1924
}
1925
1926
impl<A: Array> Iterator for IntoIter<A> {
1927
    type Item = A::Item;
1928
1929
    #[inline]
1930
2.49M
    fn next(&mut self) -> Option<A::Item> {
1931
2.49M
        if self.current == self.end {
1932
1.30M
            None
1933
        } else {
1934
            unsafe {
1935
1.19M
                let current = self.current;
1936
1.19M
                self.current += 1;
1937
1.19M
                Some(ptr::read(self.data.as_ptr().add(current)))
1938
            }
1939
        }
1940
2.49M
    }
Unexecuted instantiation: <smallvec::IntoIter<_> as core::iter::traits::iterator::Iterator>::next
Unexecuted instantiation: <smallvec::IntoIter<[base::wait_context::TriggeredEvent<<devices::virtio::vhost_user_frontend::worker::Worker>::run::Token>; 16]> as core::iter::traits::iterator::Iterator>::next
Unexecuted instantiation: <smallvec::IntoIter<[base::wait_context::TriggeredEvent<devices::virtio::interrupt::interrupt_resample_thread::Token>; 16]> as core::iter::traits::iterator::Iterator>::next
<smallvec::IntoIter<[base::volatile_memory::VolatileSlice; 16]> as core::iter::traits::iterator::Iterator>::next
Line
Count
Source
1930
2.49M
    fn next(&mut self) -> Option<A::Item> {
1931
2.49M
        if self.current == self.end {
1932
1.30M
            None
1933
        } else {
1934
            unsafe {
1935
1.19M
                let current = self.current;
1936
1.19M
                self.current += 1;
1937
1.19M
                Some(ptr::read(self.data.as_ptr().add(current)))
1938
            }
1939
        }
1940
2.49M
    }
1941
1942
    #[inline]
1943
0
    fn size_hint(&self) -> (usize, Option<usize>) {
1944
0
        let size = self.end - self.current;
1945
0
        (size, Some(size))
1946
0
    }
1947
}
1948
1949
impl<A: Array> DoubleEndedIterator for IntoIter<A> {
1950
    #[inline]
1951
0
    fn next_back(&mut self) -> Option<A::Item> {
1952
0
        if self.current == self.end {
1953
0
            None
1954
        } else {
1955
            unsafe {
1956
0
                self.end -= 1;
1957
0
                Some(ptr::read(self.data.as_ptr().add(self.end)))
1958
            }
1959
        }
1960
0
    }
1961
}
1962
1963
impl<A: Array> ExactSizeIterator for IntoIter<A> {}
1964
impl<A: Array> FusedIterator for IntoIter<A> {}
1965
1966
impl<A: Array> IntoIter<A> {
1967
    /// Returns the remaining items of this iterator as a slice.
1968
0
    pub fn as_slice(&self) -> &[A::Item] {
1969
0
        let len = self.end - self.current;
1970
0
        unsafe { core::slice::from_raw_parts(self.data.as_ptr().add(self.current), len) }
1971
0
    }
1972
1973
    /// Returns the remaining items of this iterator as a mutable slice.
1974
0
    pub fn as_mut_slice(&mut self) -> &mut [A::Item] {
1975
0
        let len = self.end - self.current;
1976
0
        unsafe { core::slice::from_raw_parts_mut(self.data.as_mut_ptr().add(self.current), len) }
1977
0
    }
1978
}
1979
1980
impl<A: Array> IntoIterator for SmallVec<A> {
1981
    type IntoIter = IntoIter<A>;
1982
    type Item = A::Item;
1983
654k
    fn into_iter(mut self) -> Self::IntoIter {
1984
        unsafe {
1985
            // Set SmallVec len to zero as `IntoIter` drop handles dropping of the elements
1986
654k
            let len = self.len();
1987
654k
            self.set_len(0);
1988
654k
            IntoIter {
1989
654k
                data: self,
1990
654k
                current: 0,
1991
654k
                end: len,
1992
654k
            }
1993
        }
1994
654k
    }
Unexecuted instantiation: <smallvec::SmallVec<_> as core::iter::traits::collect::IntoIterator>::into_iter
Unexecuted instantiation: <smallvec::SmallVec<[base::wait_context::TriggeredEvent<<devices::virtio::vhost_user_frontend::worker::Worker>::run::Token>; 16]> as core::iter::traits::collect::IntoIterator>::into_iter
Unexecuted instantiation: <smallvec::SmallVec<[base::wait_context::TriggeredEvent<devices::virtio::interrupt::interrupt_resample_thread::Token>; 16]> as core::iter::traits::collect::IntoIterator>::into_iter
<smallvec::SmallVec<[base::volatile_memory::VolatileSlice; 16]> as core::iter::traits::collect::IntoIterator>::into_iter
Line
Count
Source
1983
654k
    fn into_iter(mut self) -> Self::IntoIter {
1984
        unsafe {
1985
            // Set SmallVec len to zero as `IntoIter` drop handles dropping of the elements
1986
654k
            let len = self.len();
1987
654k
            self.set_len(0);
1988
654k
            IntoIter {
1989
654k
                data: self,
1990
654k
                current: 0,
1991
654k
                end: len,
1992
654k
            }
1993
        }
1994
654k
    }
1995
}
1996
1997
impl<'a, A: Array> IntoIterator for &'a SmallVec<A> {
1998
    type IntoIter = slice::Iter<'a, A::Item>;
1999
    type Item = &'a A::Item;
2000
0
    fn into_iter(self) -> Self::IntoIter {
2001
0
        self.iter()
2002
0
    }
Unexecuted instantiation: <&smallvec::SmallVec<_> as core::iter::traits::collect::IntoIterator>::into_iter
Unexecuted instantiation: <&smallvec::SmallVec<[base::wait_context::TriggeredEvent<<devices::virtio::wl::Worker>::run::Token>; 16]> as core::iter::traits::collect::IntoIterator>::into_iter
2003
}
2004
2005
impl<'a, A: Array> IntoIterator for &'a mut SmallVec<A> {
2006
    type IntoIter = slice::IterMut<'a, A::Item>;
2007
    type Item = &'a mut A::Item;
2008
0
    fn into_iter(self) -> Self::IntoIter {
2009
0
        self.iter_mut()
2010
0
    }
2011
}
2012
2013
/// Types that can be used as the backing store for a SmallVec
2014
pub unsafe trait Array {
2015
    /// The type of the array's elements.
2016
    type Item;
2017
    /// Returns the number of items the array can hold.
2018
    fn size() -> usize;
2019
}
2020
2021
/// Set the length of the vec when the `SetLenOnDrop` value goes out of scope.
2022
///
2023
/// Copied from https://github.com/rust-lang/rust/pull/36355
2024
struct SetLenOnDrop<'a> {
2025
    len: &'a mut usize,
2026
    local_len: usize,
2027
}
2028
2029
impl<'a> SetLenOnDrop<'a> {
2030
    #[inline]
2031
893k
    fn new(len: &'a mut usize) -> Self {
2032
893k
        SetLenOnDrop {
2033
893k
            local_len: *len,
2034
893k
            len,
2035
893k
        }
2036
893k
    }
Unexecuted instantiation: <smallvec::SetLenOnDrop>::new
<smallvec::SetLenOnDrop>::new
Line
Count
Source
2031
893k
    fn new(len: &'a mut usize) -> Self {
2032
893k
        SetLenOnDrop {
2033
893k
            local_len: *len,
2034
893k
            len,
2035
893k
        }
2036
893k
    }
Unexecuted instantiation: <smallvec::SetLenOnDrop>::new
Unexecuted instantiation: <smallvec::SetLenOnDrop>::new
2037
2038
    #[inline]
2039
3.77M
    fn get(&self) -> usize {
2040
3.77M
        self.local_len
2041
3.77M
    }
Unexecuted instantiation: <smallvec::SetLenOnDrop>::get
<smallvec::SetLenOnDrop>::get
Line
Count
Source
2039
3.77M
    fn get(&self) -> usize {
2040
3.77M
        self.local_len
2041
3.77M
    }
Unexecuted instantiation: <smallvec::SetLenOnDrop>::get
Unexecuted instantiation: <smallvec::SetLenOnDrop>::get
2042
2043
    #[inline]
2044
1.43M
    fn increment_len(&mut self, increment: usize) {
2045
1.43M
        self.local_len += increment;
2046
1.43M
    }
Unexecuted instantiation: <smallvec::SetLenOnDrop>::increment_len
<smallvec::SetLenOnDrop>::increment_len
Line
Count
Source
2044
1.43M
    fn increment_len(&mut self, increment: usize) {
2045
1.43M
        self.local_len += increment;
2046
1.43M
    }
Unexecuted instantiation: <smallvec::SetLenOnDrop>::increment_len
Unexecuted instantiation: <smallvec::SetLenOnDrop>::increment_len
2047
}
2048
2049
impl<'a> Drop for SetLenOnDrop<'a> {
2050
    #[inline]
2051
893k
    fn drop(&mut self) {
2052
893k
        *self.len = self.local_len;
2053
893k
    }
Unexecuted instantiation: <smallvec::SetLenOnDrop as core::ops::drop::Drop>::drop
<smallvec::SetLenOnDrop as core::ops::drop::Drop>::drop
Line
Count
Source
2051
893k
    fn drop(&mut self) {
2052
893k
        *self.len = self.local_len;
2053
893k
    }
Unexecuted instantiation: <smallvec::SetLenOnDrop as core::ops::drop::Drop>::drop
2054
}
2055
2056
#[cfg(feature = "const_new")]
2057
impl<T, const N: usize> SmallVec<[T; N]> {
2058
    /// Construct an empty vector.
2059
    ///
2060
    /// This is a `const` version of [`SmallVec::new`] that is enabled by the feature `const_new`, with the limitation that it only works for arrays.
2061
    #[cfg_attr(docsrs, doc(cfg(feature = "const_new")))]
2062
    #[inline]
2063
    pub const fn new_const() -> Self {
2064
        SmallVec {
2065
            capacity: 0,
2066
            data: SmallVecData::from_const(MaybeUninit::uninit()),
2067
        }
2068
    }
2069
2070
    /// The array passed as an argument is moved to be an inline version of `SmallVec`.
2071
    ///
2072
    /// This is a `const` version of [`SmallVec::from_buf`] that is enabled by the feature `const_new`, with the limitation that it only works for arrays.
2073
    #[cfg_attr(docsrs, doc(cfg(feature = "const_new")))]
2074
    #[inline]
2075
    pub const fn from_const(items: [T; N]) -> Self {
2076
        SmallVec {
2077
            capacity: N,
2078
            data: SmallVecData::from_const(MaybeUninit::new(items)),
2079
        }
2080
    }
2081
}
2082
2083
#[cfg(all(feature = "const_generics", not(doc)))]
2084
#[cfg_attr(docsrs, doc(cfg(feature = "const_generics")))]
2085
unsafe impl<T, const N: usize> Array for [T; N] {
2086
    type Item = T;
2087
    fn size() -> usize {
2088
        N
2089
    }
2090
}
2091
2092
#[cfg(any(not(feature = "const_generics"), doc))]
2093
macro_rules! impl_array(
2094
    ($($size:expr),+) => {
2095
        $(
2096
            unsafe impl<T> Array for [T; $size] {
2097
                type Item = T;
2098
35.9M
                fn size() -> usize { $size }
Unexecuted instantiation: <[_; 8] as smallvec::Array>::size
Unexecuted instantiation: <[_; 9] as smallvec::Array>::size
Unexecuted instantiation: <[_; 10] as smallvec::Array>::size
Unexecuted instantiation: <[_; 11] as smallvec::Array>::size
Unexecuted instantiation: <[_; 12] as smallvec::Array>::size
Unexecuted instantiation: <[_; 13] as smallvec::Array>::size
Unexecuted instantiation: <[_; 14] as smallvec::Array>::size
Unexecuted instantiation: <[_; 15] as smallvec::Array>::size
Unexecuted instantiation: <[_; 16] as smallvec::Array>::size
Unexecuted instantiation: <[_; 17] as smallvec::Array>::size
Unexecuted instantiation: <[_; 16384] as smallvec::Array>::size
Unexecuted instantiation: <[_; 24576] as smallvec::Array>::size
Unexecuted instantiation: <[_; 32768] as smallvec::Array>::size
Unexecuted instantiation: <[_; 65536] as smallvec::Array>::size
Unexecuted instantiation: <[_; 131072] as smallvec::Array>::size
Unexecuted instantiation: <[_; 262144] as smallvec::Array>::size
Unexecuted instantiation: <[_; 393216] as smallvec::Array>::size
Unexecuted instantiation: <[_; 524288] as smallvec::Array>::size
Unexecuted instantiation: <[_; 1048576] as smallvec::Array>::size
Unexecuted instantiation: <[_; 18] as smallvec::Array>::size
Unexecuted instantiation: <[_; 19] as smallvec::Array>::size
Unexecuted instantiation: <[_; 20] as smallvec::Array>::size
Unexecuted instantiation: <[_; 21] as smallvec::Array>::size
Unexecuted instantiation: <[_; 22] as smallvec::Array>::size
Unexecuted instantiation: <[_; 23] as smallvec::Array>::size
Unexecuted instantiation: <[_; 24] as smallvec::Array>::size
Unexecuted instantiation: <[_; 25] as smallvec::Array>::size
Unexecuted instantiation: <[_; 26] as smallvec::Array>::size
Unexecuted instantiation: <[_; 27] as smallvec::Array>::size
Unexecuted instantiation: <[_; 28] as smallvec::Array>::size
Unexecuted instantiation: <[_; 29] as smallvec::Array>::size
Unexecuted instantiation: <[_; 30] as smallvec::Array>::size
Unexecuted instantiation: <[_; 31] as smallvec::Array>::size
Unexecuted instantiation: <[_; 32] as smallvec::Array>::size
Unexecuted instantiation: <[_; 36] as smallvec::Array>::size
Unexecuted instantiation: <[_; 64] as smallvec::Array>::size
Unexecuted instantiation: <[_; 96] as smallvec::Array>::size
Unexecuted instantiation: <[_; 128] as smallvec::Array>::size
Unexecuted instantiation: <[_; 256] as smallvec::Array>::size
Unexecuted instantiation: <[_; 512] as smallvec::Array>::size
Unexecuted instantiation: <[_; 1024] as smallvec::Array>::size
Unexecuted instantiation: <[_; 1536] as smallvec::Array>::size
Unexecuted instantiation: <[_; 2048] as smallvec::Array>::size
Unexecuted instantiation: <[_; 4096] as smallvec::Array>::size
Unexecuted instantiation: <[_; 8192] as smallvec::Array>::size
Unexecuted instantiation: <[_; 0] as smallvec::Array>::size
Unexecuted instantiation: <[_; 1] as smallvec::Array>::size
Unexecuted instantiation: <[_; 2] as smallvec::Array>::size
Unexecuted instantiation: <[_; 3] as smallvec::Array>::size
Unexecuted instantiation: <[_; 4] as smallvec::Array>::size
Unexecuted instantiation: <[_; 5] as smallvec::Array>::size
Unexecuted instantiation: <[_; 6] as smallvec::Array>::size
Unexecuted instantiation: <[_; 7] as smallvec::Array>::size
Unexecuted instantiation: <[base::wait_context::TriggeredEvent<<devices::serial::Serial>::spawn_input_thread::{closure#0}::Token>; 16] as smallvec::Array>::size
Unexecuted instantiation: <[base::wait_context::TriggeredEvent<devices::bat::Token>; 16] as smallvec::Array>::size
Unexecuted instantiation: <[base::wait_context::TriggeredEvent<devices::pit::Token>; 16] as smallvec::Array>::size
Unexecuted instantiation: <[base::wait_context::TriggeredEvent<devices::virtio::console::worker::Token>; 16] as smallvec::Array>::size
Unexecuted instantiation: <[base::wait_context::TriggeredEvent<<devices::vmwdt::Vmwdt>::vmwdt_worker_thread::Token>; 16] as smallvec::Array>::size
Unexecuted instantiation: <[base::wait_context::TriggeredEvent<<devices::virtio::p9::Worker>::run::Token>; 16] as smallvec::Array>::size
Unexecuted instantiation: <[base::wait_context::TriggeredEvent<<devices::virtio::rng::Worker>::run::Token>; 16] as smallvec::Array>::size
Unexecuted instantiation: <[base::wait_context::TriggeredEvent<<devices::virtio::vhost_user_frontend::worker::Worker>::run::Token>; 16] as smallvec::Array>::size
Unexecuted instantiation: <[base::wait_context::TriggeredEvent<<devices::virtio::vhost::worker::Worker<_>>::run::Token>; 16] as smallvec::Array>::size
Unexecuted instantiation: <[base::wait_context::TriggeredEvent<<devices::pci::coiommu::PinWorker>::run::Token>; 16] as smallvec::Array>::size
Unexecuted instantiation: <[base::wait_context::TriggeredEvent<<devices::pci::coiommu::UnpinWorker>::run::Token>; 16] as smallvec::Array>::size
Unexecuted instantiation: <[base::wait_context::TriggeredEvent<<devices::pci::vfio_pci::VfioPciWorker>::run::Token>; 16] as smallvec::Array>::size
Unexecuted instantiation: <[base::wait_context::TriggeredEvent<<devices::virtio::fs::worker::Worker<_>>::run::Token>; 16] as smallvec::Array>::size
Unexecuted instantiation: <[base::wait_context::TriggeredEvent<<devices::virtio::wl::Worker>::run::Token>; 16] as smallvec::Array>::size
Unexecuted instantiation: <[base::wait_context::TriggeredEvent<devices::virtcpufreq_v2::vcpufreq_worker_thread::Token>; 16] as smallvec::Array>::size
Unexecuted instantiation: <[base::wait_context::TriggeredEvent<devices::acpi::run_worker::Token>; 16] as smallvec::Array>::size
Unexecuted instantiation: <[base::wait_context::TriggeredEvent<devices::cmos::run_cmos_worker::Token>; 16] as smallvec::Array>::size
Unexecuted instantiation: <[base::wait_context::TriggeredEvent<devices::virtio::interrupt::interrupt_resample_thread::Token>; 16] as smallvec::Array>::size
Unexecuted instantiation: <[base::wait_context::TriggeredEvent<devices::virtio::console::sys::linux::read_input::Token>; 16] as smallvec::Array>::size
Unexecuted instantiation: <[base::wait_context::TriggeredEvent<u32>; 16] as smallvec::Array>::size
<[cros_async::mem::MemRegion; 2] as smallvec::Array>::size
Line
Count
Source
2098
25.7M
                fn size() -> usize { $size }
<[base::volatile_memory::VolatileSlice; 16] as smallvec::Array>::size
Line
Count
Source
2098
10.2M
                fn size() -> usize { $size }
Unexecuted instantiation: <[devices::virtio::iommu::memory_mapper::MemRegion; 1] as smallvec::Array>::size
Unexecuted instantiation: <[base::wait_context::TriggeredEvent<metrics::controller::MetricsControllerToken>; 16] as smallvec::Array>::size
Unexecuted instantiation: <[base::wait_context::TriggeredEvent<usize>; 16] as smallvec::Array>::size
2099
            }
2100
        )+
2101
    }
2102
);
2103
2104
#[cfg(any(not(feature = "const_generics"), doc))]
2105
impl_array!(
2106
    0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25,
2107
    26, 27, 28, 29, 30, 31, 32, 36, 0x40, 0x60, 0x80, 0x100, 0x200, 0x400, 0x600, 0x800, 0x1000,
2108
    0x2000, 0x4000, 0x6000, 0x8000, 0x10000, 0x20000, 0x40000, 0x60000, 0x80000, 0x10_0000
2109
);
2110
2111
/// Convenience trait for constructing a `SmallVec`
2112
pub trait ToSmallVec<A: Array> {
2113
    /// Construct a new `SmallVec` from a slice.
2114
    fn to_smallvec(&self) -> SmallVec<A>;
2115
}
2116
2117
impl<A: Array> ToSmallVec<A> for [A::Item]
2118
where
2119
    A::Item: Copy,
2120
{
2121
    #[inline]
2122
0
    fn to_smallvec(&self) -> SmallVec<A> {
2123
0
        SmallVec::from_slice(self)
2124
0
    }
2125
}