aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authornsfisis <nsfisis@gmail.com>2024-07-15 21:33:49 +0900
committernsfisis <nsfisis@gmail.com>2024-07-15 21:33:49 +0900
commit73d3848797be013c069fb2c6fa77050e92bc17b2 (patch)
tree72772290aa41689c9fce5cc9ec6db333466d31c3
parentf75a32ed1304195c365e7c51184110008c974176 (diff)
downloadreparojson-73d3848797be013c069fb2c6fa77050e92bc17b2.tar.gz
reparojson-73d3848797be013c069fb2c6fa77050e92bc17b2.tar.zst
reparojson-73d3848797be013c069fb2c6fa77050e92bc17b2.zip
refactor: remove unnecessary mutability
-rw-r--r--src/lib.rs22
1 files changed, 12 insertions, 10 deletions
diff --git a/src/lib.rs b/src/lib.rs
index 90c3bab..3710e7d 100644
--- a/src/lib.rs
+++ b/src/lib.rs
@@ -244,11 +244,12 @@ impl Parser {
match *next {
b'}' => {
- w.write_all(&mut ws)?;
+ w.write_all(&ws)?;
return Ok(());
}
b',' => {
- w.write_all(&mut ws)?;
+ w.write_all(&ws)?;
+ // Re-use the memory buffer to avoid another allocation.
ws.clear();
input.next();
@@ -264,19 +265,19 @@ impl Parser {
match *c {
b'}' => {
self.repaired = true;
- w.write_all(&mut ws)?;
+ w.write_all(&ws)?;
return Ok(());
}
_ => {
w.write_all(b",")?;
- w.write_all(&mut ws)?;
+ w.write_all(&ws)?;
}
}
}
_ => {
self.repaired = true;
w.write_all(b",")?;
- w.write_all(&mut ws)?;
+ w.write_all(&ws)?;
}
}
}
@@ -366,11 +367,12 @@ impl Parser {
match *next {
b']' => {
- w.write_all(&mut ws)?;
+ w.write_all(&ws)?;
return Ok(());
}
b',' => {
- w.write_all(&mut ws)?;
+ w.write_all(&ws)?;
+ // Re-use the memory buffer to avoid another allocation.
ws.clear();
input.next();
@@ -386,19 +388,19 @@ impl Parser {
match *c {
b']' => {
self.repaired = true;
- w.write_all(&mut ws)?;
+ w.write_all(&ws)?;
return Ok(());
}
_ => {
w.write_all(b",")?;
- w.write_all(&mut ws)?;
+ w.write_all(&ws)?;
}
}
}
_ => {
self.repaired = true;
w.write_all(b",")?;
- w.write_all(&mut ws)?;
+ w.write_all(&ws)?;
}
}
}