mirror of
https://github.com/roc-lang/roc.git
synced 2024-09-22 00:09:33 +03:00
use std::io::Write to write bytes
This commit is contained in:
parent
3e0b598bc7
commit
b761890f47
@ -639,18 +639,13 @@ impl IdentIds {
|
|||||||
/// This is used, for example, during canonicalization of an Expr::Closure
|
/// This is used, for example, during canonicalization of an Expr::Closure
|
||||||
/// to generate a unique symbol to refer to that closure.
|
/// to generate a unique symbol to refer to that closure.
|
||||||
pub fn gen_unique(&mut self) -> IdentId {
|
pub fn gen_unique(&mut self) -> IdentId {
|
||||||
use std::fmt::Write;
|
use std::io::Write;
|
||||||
|
|
||||||
let index = self.lengths.len();
|
let index = self.lengths.len();
|
||||||
|
|
||||||
// "4294967296" is 10 characters
|
|
||||||
let mut buffer: arrayvec::ArrayString<10> = arrayvec::ArrayString::new();
|
|
||||||
write!(buffer, "{}", index).unwrap();
|
|
||||||
|
|
||||||
let offset = self.buffer.len();
|
let offset = self.buffer.len();
|
||||||
let length = buffer.len();
|
write!(self.buffer, "{}", index).unwrap();
|
||||||
|
let length = self.buffer.len() - offset;
|
||||||
self.buffer.extend(buffer.bytes());
|
|
||||||
|
|
||||||
self.lengths.push(length as u16);
|
self.lengths.push(length as u16);
|
||||||
self.offsets.push(offset as u32);
|
self.offsets.push(offset as u32);
|
||||||
|
Loading…
Reference in New Issue
Block a user