Skip to content

Commit 720a2c6

Browse files
bors[bot]burrbull
andauthored
Merge #105
105: rayon r=therealprof a=burrbull Slight speed-up with `rayon` Co-authored-by: Andrey Zgarbul <zgarbul.andrey@gmail.com>
2 parents e55aa96 + 7b7c548 commit 720a2c6

File tree

3 files changed

+17
-17
lines changed

3 files changed

+17
-17
lines changed

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,10 +18,10 @@ derive-from = []
1818
unproven = []
1919

2020
[dependencies]
21-
either = "1.5"
2221
xmltree = "0.8"
2322
anyhow = "1.0.19"
2423
thiserror = "1.0.5"
24+
rayon = "1.3.0"
2525

2626
[dependencies.serde]
2727
version = "1.0"

src/svd/bitrange.rs

Lines changed: 13 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -92,21 +92,19 @@ impl Parse for BitRange {
9292
} else if let (Some(offset), Some(width)) =
9393
(tree.get_child("bitOffset"), tree.get_child("bitWidth"))
9494
{
95-
(
96-
// Special case because offset and width are directly provided
97-
// (ie. do not need to be calculated as in the final step)
98-
return Ok(BitRange {
99-
// TODO: capture that error comes from offset/width tag
100-
// TODO: `u32::parse` should not hide it's errors
101-
offset: u32::parse(offset).with_context(|| {
102-
SVDError::InvalidBitRange(tree.clone(), InvalidBitRange::ParseError)
103-
})?,
104-
width: u32::parse(width).with_context(|| {
105-
SVDError::InvalidBitRange(tree.clone(), InvalidBitRange::ParseError)
106-
})?,
107-
range_type: BitRangeType::OffsetWidth,
108-
})
109-
)
95+
// Special case because offset and width are directly provided
96+
// (ie. do not need to be calculated as in the final step)
97+
return Ok(BitRange {
98+
// TODO: capture that error comes from offset/width tag
99+
// TODO: `u32::parse` should not hide it's errors
100+
offset: u32::parse(offset).with_context(|| {
101+
SVDError::InvalidBitRange(tree.clone(), InvalidBitRange::ParseError)
102+
})?,
103+
width: u32::parse(width).with_context(|| {
104+
SVDError::InvalidBitRange(tree.clone(), InvalidBitRange::ParseError)
105+
})?,
106+
range_type: BitRangeType::OffsetWidth,
107+
});
110108
} else {
111109
return Err(SVDError::InvalidBitRange(tree.clone(), InvalidBitRange::Syntax).into());
112110
};

src/svd/device.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@ use crate::elementext::ElementExt;
33
use std::collections::HashMap;
44
use xmltree::Element;
55

6+
use rayon::prelude::*;
7+
68
use crate::parse;
79
use crate::types::Parse;
810

@@ -47,7 +49,7 @@ impl Parse for Device {
4749
let ps: Result<Vec<_>, _> = tree
4850
.get_child_elem("peripherals")?
4951
.children
50-
.iter()
52+
.par_iter()
5153
.map(Peripheral::parse)
5254
.collect();
5355
ps?

0 commit comments

Comments
 (0)