diff options
| author | Vadim Petrochenkov <vadim.petrochenkov@gmail.com> | 2022-11-22 20:01:44 +0300 |
|---|---|---|
| committer | Vadim Petrochenkov <vadim.petrochenkov@gmail.com> | 2022-11-22 20:43:48 +0300 |
| commit | 6a233b5e2ab6a59bc32f052d9ecf8b89b4bcf030 (patch) | |
| tree | 169f416f2a4a7bc868a2800a8c8fd41fbfcaff11 /compiler/rustc_metadata/src/rmeta/decoder | |
| parent | f3b5791a47eea13cb1d3fec644fc0c6ea9c37c96 (diff) | |
| download | rust-6a233b5e2ab6a59bc32f052d9ecf8b89b4bcf030.tar.gz rust-6a233b5e2ab6a59bc32f052d9ecf8b89b4bcf030.zip | |
rustc_metadata: Switch module children decoding to an iterator
Diffstat (limited to 'compiler/rustc_metadata/src/rmeta/decoder')
| -rw-r--r-- | compiler/rustc_metadata/src/rmeta/decoder/cstore_impl.rs | 19 |
1 files changed, 7 insertions, 12 deletions
diff --git a/compiler/rustc_metadata/src/rmeta/decoder/cstore_impl.rs b/compiler/rustc_metadata/src/rmeta/decoder/cstore_impl.rs index d96252ba569..33cce0a411e 100644 --- a/compiler/rustc_metadata/src/rmeta/decoder/cstore_impl.rs +++ b/compiler/rustc_metadata/src/rmeta/decoder/cstore_impl.rs @@ -21,7 +21,6 @@ use rustc_span::source_map::{Span, Spanned}; use rustc_span::symbol::{kw, Symbol}; use rustc_data_structures::sync::Lrc; -use smallvec::SmallVec; use std::any::Any; use super::{Decodable, DecodeContext, DecodeIterator}; @@ -298,9 +297,7 @@ provide! { tcx, def_id, other, cdata, r } module_children => { - let mut result = SmallVec::<[_; 8]>::new(); - cdata.for_each_module_child(def_id.index, |child| result.push(child), tcx.sess); - tcx.arena.alloc_slice(&result) + tcx.arena.alloc_from_iter(cdata.get_module_children(def_id.index, tcx.sess)) } defined_lib_features => { cdata.get_lib_features(tcx) } stability_implications => { @@ -503,14 +500,12 @@ impl CStore { self.get_crate_data(def.krate).get_visibility(def.index) } - pub fn module_children_untracked(&self, def_id: DefId, sess: &Session) -> Vec<ModChild> { - let mut result = vec![]; - self.get_crate_data(def_id.krate).for_each_module_child( - def_id.index, - |child| result.push(child), - sess, - ); - result + pub fn module_children_untracked<'a>( + &'a self, + def_id: DefId, + sess: &'a Session, + ) -> impl Iterator<Item = ModChild> + 'a { + self.get_crate_data(def_id.krate).get_module_children(def_id.index, sess) } pub fn load_macro_untracked(&self, id: DefId, sess: &Session) -> LoadedMacro { |
