diff options
| author | nsfisis <nsfisis@gmail.com> | 2024-07-15 21:33:49 +0900 |
|---|---|---|
| committer | nsfisis <nsfisis@gmail.com> | 2024-07-15 21:33:49 +0900 |
| commit | 73d3848797be013c069fb2c6fa77050e92bc17b2 (patch) | |
| tree | 72772290aa41689c9fce5cc9ec6db333466d31c3 /src | |
| parent | f75a32ed1304195c365e7c51184110008c974176 (diff) | |
| download | reparojson-73d3848797be013c069fb2c6fa77050e92bc17b2.tar.gz reparojson-73d3848797be013c069fb2c6fa77050e92bc17b2.tar.zst reparojson-73d3848797be013c069fb2c6fa77050e92bc17b2.zip | |
refactor: remove unnecessary mutability
Diffstat (limited to 'src')
| -rw-r--r-- | src/lib.rs | 22 |
1 files changed, 12 insertions, 10 deletions
@@ -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)?; } } } |
