perf(gpg-agent): reuse buffer for signature

This commit is contained in:
Anna 2023-08-31 16:31:28 -04:00
parent fae0b36248
commit fae0dae758
Signed by: anna
GPG Key ID: D0943384CD9F87D1
1 changed files with 3 additions and 3 deletions

View File

@ -557,13 +557,13 @@ fn main() -> Result<()> {
// NOTE: don't need to handle append here, since we'll never be
// both appending *and* signing
if let Some(ctx) = &mut gpg {
signature_bytes.clear();
let to_sign = format!("{header}\n{message}");
let mut output = Vec::new();
ctx.sign(SignMode::Detached, to_sign, &mut output)
ctx.sign(SignMode::Detached, to_sign, &mut signature_bytes)
.context("could not sign commit")
.unwrap(); // FIXME
let sig = String::from_utf8(output)
let sig = std::str::from_utf8(&signature_bytes)
.context("signature was not utf-8")
.unwrap(); // FIXME