Use .extend(..) instead of push()-ing in loop
A bit less readable but more compact, and maybe faster? We'll see.
This commit is contained in:
parent
2b14529a7c
commit
5f2c6b92d1
@ -1319,24 +1319,18 @@ impl<D: Decoder> Decodable<D> for SourceFile {
|
|||||||
lines.push(line_start);
|
lines.push(line_start);
|
||||||
|
|
||||||
match bytes_per_diff {
|
match bytes_per_diff {
|
||||||
1 => {
|
1 => lines.extend((1..num_lines).map(|_| {
|
||||||
for _ in 1..num_lines {
|
line_start = line_start + BytePos(d.read_u8() as u32);
|
||||||
line_start = line_start + BytePos(d.read_u8() as u32);
|
line_start
|
||||||
lines.push(line_start);
|
})),
|
||||||
}
|
2 => lines.extend((1..num_lines).map(|_| {
|
||||||
}
|
line_start = line_start + BytePos(d.read_u16() as u32);
|
||||||
2 => {
|
line_start
|
||||||
for _ in 1..num_lines {
|
})),
|
||||||
line_start = line_start + BytePos(d.read_u16() as u32);
|
4 => lines.extend((1..num_lines).map(|_| {
|
||||||
lines.push(line_start);
|
line_start = line_start + BytePos(d.read_u32());
|
||||||
}
|
line_start
|
||||||
}
|
})),
|
||||||
4 => {
|
|
||||||
for _ in 1..num_lines {
|
|
||||||
line_start = line_start + BytePos(d.read_u32());
|
|
||||||
lines.push(line_start);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
_ => unreachable!(),
|
_ => unreachable!(),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user