]> git.lizzy.rs Git - rust.git/commit
Replace `rustc_data_structures::thin_vec::ThinVec` with `thin_vec::ThinVec`.
authorNicholas Nethercote <n.nethercote@gmail.com>
Wed, 17 Aug 2022 04:22:30 +0000 (14:22 +1000)
committerNicholas Nethercote <n.nethercote@gmail.com>
Mon, 29 Aug 2022 05:42:13 +0000 (15:42 +1000)
commitb38106b6d8478fbfbded5403ee31c056c71cef48
treef5ba97063be433b2d8c8099f7312853a24ac8fb8
parent223d16ebbde1bd309c58e853b053e14318e56b0e
Replace `rustc_data_structures::thin_vec::ThinVec` with `thin_vec::ThinVec`.

`rustc_data_structures::thin_vec::ThinVec` looks like this:
```
pub struct ThinVec<T>(Option<Box<Vec<T>>>);
```
It's just a zero word if the vector is empty, but requires two
allocations if it is non-empty. So it's only usable in cases where the
vector is empty most of the time.

This commit removes it in favour of `thin_vec::ThinVec`, which is also
word-sized, but stores the length and capacity in the same allocation as
the elements. It's good in a wider variety of situation, e.g. in enum
variants where the vector is usually/always non-empty.

The commit also:
- Sorts some `Cargo.toml` dependency lists, to make additions easier.
- Sorts some `use` item lists, to make additions easier.
- Changes `clean_trait_ref_with_bindings` to take a
  `ThinVec<TypeBinding>` rather than a `&[TypeBinding]`, because this
  avoid some unnecessary allocations.
42 files changed:
Cargo.lock
compiler/rustc_ast/Cargo.toml
compiler/rustc_ast/src/ast.rs
compiler/rustc_ast/src/tokenstream.rs
compiler/rustc_ast_lowering/Cargo.toml
compiler/rustc_ast_lowering/src/expr.rs
compiler/rustc_builtin_macros/Cargo.toml
compiler/rustc_builtin_macros/src/assert/context.rs
compiler/rustc_builtin_macros/src/deriving/clone.rs
compiler/rustc_builtin_macros/src/deriving/cmp/eq.rs
compiler/rustc_builtin_macros/src/deriving/cmp/ord.rs
compiler/rustc_builtin_macros/src/deriving/cmp/partial_eq.rs
compiler/rustc_builtin_macros/src/deriving/cmp/partial_ord.rs
compiler/rustc_builtin_macros/src/deriving/default.rs
compiler/rustc_builtin_macros/src/deriving/generic/mod.rs
compiler/rustc_builtin_macros/src/global_allocator.rs
compiler/rustc_builtin_macros/src/standard_library_imports.rs
compiler/rustc_builtin_macros/src/test.rs
compiler/rustc_builtin_macros/src/test_harness.rs
compiler/rustc_data_structures/Cargo.toml
compiler/rustc_data_structures/src/lib.rs
compiler/rustc_data_structures/src/map_in_place.rs
compiler/rustc_data_structures/src/thin_vec.rs [deleted file]
compiler/rustc_data_structures/src/thin_vec/tests.rs [deleted file]
compiler/rustc_middle/Cargo.toml
compiler/rustc_middle/src/ty/context.rs
compiler/rustc_parse/src/parser/attr_wrapper.rs
compiler/rustc_query_impl/Cargo.toml
compiler/rustc_query_impl/src/plumbing.rs
compiler/rustc_query_system/Cargo.toml
compiler/rustc_query_system/src/query/mod.rs
compiler/rustc_query_system/src/query/plumbing.rs
compiler/rustc_serialize/Cargo.toml
compiler/rustc_serialize/src/collection_impls.rs
src/librustdoc/Cargo.toml
src/librustdoc/clean/auto_trait.rs
src/librustdoc/clean/blanket_impl.rs
src/librustdoc/clean/inline.rs
src/librustdoc/clean/mod.rs
src/librustdoc/clean/types.rs
src/librustdoc/clean/utils.rs
src/tools/tidy/src/deps.rs