Avoid reallocation when ensuring trailing newline

This commit is contained in:
Richard Feldman 2022-03-06 11:08:59 -05:00
parent da5fdf6d2f
commit 8f6f20b57d
No known key found for this signature in database
GPG key ID: 7E4127D1E4241798
2 changed files with 44 additions and 5 deletions

View file

@ -181,8 +181,7 @@ fn fmt_all<'a>(arena: &'a Bump, buf: &mut Buf<'a>, ast: &'a Ast) {
fmt_def(buf, arena.alloc(def.value), 0);
}
buf.trim_end();
buf.newline();
buf.fmt_end_of_file();
}
/// RemoveSpaces normalizes the ast to something that we _expect_ to be invariant under formatting.