Skip to content

Commit 9281a56

Browse files
committed
More De-Vec-torisation of TokenStreams
Signed-off-by: Daniel Egger <[email protected]>
1 parent 7a9ef9f commit 9281a56

File tree

1 file changed

+9
-17
lines changed

1 file changed

+9
-17
lines changed

src/generate/register.rs

Lines changed: 9 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -43,8 +43,8 @@ pub fn render(
4343
);
4444

4545
let mut mod_items = TokenStream::new();
46-
let mut r_impl_items = vec![];
47-
let mut w_impl_items = vec![];
46+
let mut r_impl_items = TokenStream::new();
47+
let mut w_impl_items = TokenStream::new();
4848
let mut methods = vec![];
4949

5050
let can_read = [Access::ReadOnly, Access::ReadWriteOnce, Access::ReadWrite].contains(&access);
@@ -132,11 +132,7 @@ pub fn render(
132132
impl W #open
133133
});
134134

135-
for item in w_impl_items {
136-
mod_items.extend(quote! {
137-
#item
138-
});
139-
}
135+
mod_items.extend(w_impl_items);
140136

141137
mod_items.extend(quote! {
142138
#close
@@ -193,11 +189,7 @@ pub fn render(
193189
pub mod #name_sc #open
194190
});
195191

196-
for item in mod_items {
197-
out.extend(quote! {
198-
#item
199-
});
200-
}
192+
out.extend(mod_items);
201193

202194
out.extend(quote! {
203195
#close
@@ -216,8 +208,8 @@ pub fn fields(
216208
reset_value: Option<u64>,
217209
access: Access,
218210
mod_items: &mut TokenStream,
219-
r_impl_items: &mut Vec<TokenStream>,
220-
w_impl_items: &mut Vec<TokenStream>,
211+
r_impl_items: &mut TokenStream,
212+
w_impl_items: &mut TokenStream,
221213
) -> Result<()> {
222214
// TODO enumeratedValues
223215
for f in fields.into_iter() {
@@ -293,7 +285,7 @@ pub fn fields(
293285
if let Some((evs, base)) = lookup_filter(&lookup_results, Usage::Read) {
294286
evs_r = Some(evs.clone());
295287

296-
r_impl_items.push(quote! {
288+
r_impl_items.extend(quote! {
297289
#[doc = #description_with_bits]
298290
#[inline(always)]
299291
pub fn #sc(&self) -> #_pc_r {
@@ -399,7 +391,7 @@ pub fn fields(
399391
});
400392
}
401393
} else {
402-
r_impl_items.push(quote! {
394+
r_impl_items.extend(quote! {
403395
#[doc = #description_with_bits]
404396
#[inline(always)]
405397
pub fn #sc(&self) -> #_pc_r {
@@ -514,7 +506,7 @@ pub fn fields(
514506
}
515507
});
516508

517-
w_impl_items.push(quote! {
509+
w_impl_items.extend(quote! {
518510
#[doc = #description_with_bits]
519511
#[inline(always)]
520512
pub fn #sc(&mut self) -> #_pc_w {

0 commit comments

Comments
 (0)