Skip to content

Commit

Permalink
feat: avoid an allocation
Browse files Browse the repository at this point in the history
  • Loading branch information
cyril-marpaud authored and banditopazzo committed Oct 7, 2023
1 parent e993d55 commit a5d4b74
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions kepler/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ use domain_db::{cve_sources::nist, db};
use dotenvy::dotenv;
use env_logger::Env;
use lazy_static::lazy_static;
use std::borrow::Cow;
use std::{fs, path::Path};

mod api;
Expand Down Expand Up @@ -184,11 +185,11 @@ pub fn import_nist(
Ok(num_imported)
}

fn report_message(num_records: u32) -> String {
fn report_message(num_records: u32) -> Cow<'static, str> {
if num_records == 0 {
"No new records created".to_string()
Cow::Borrowed("No new records created")
} else {
format!("{num_records} new records created")
Cow::Owned(format!("{num_records} new records created"))
}
}

Expand Down

0 comments on commit a5d4b74

Please sign in to comment.