From eb892dccad7ff028f9b5930ad26a84ec6afa414b Mon Sep 17 00:00:00 2001 From: shenjack <3695888@qq.com> Date: Thu, 29 Feb 2024 00:36:28 +0800 Subject: [PATCH] en? --- Cargo.toml | 6 +++++- src/main.rs | 4 ++-- src/name.rs | 20 +++++++++++++++++--- 3 files changed, 24 insertions(+), 6 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 5bd65a5..6bd34eb 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -18,5 +18,9 @@ tracing = "0.1.40" tracing-subscriber = { version = "0.3.18", features = ["time"] } [profile.release] -opt-level = 0 +opt-level = 3 codegen-units = 1 +panic = "abort" +debug = false +lto = true +overflow-checks = false diff --git a/src/main.rs b/src/main.rs index 4c9a535..841709a 100644 --- a/src/main.rs +++ b/src/main.rs @@ -44,8 +44,8 @@ fn cacl(max: u64, step: usize, top: u32, id: u64) { let mut k: u64 = 0; let mut top = top; for i in (0+id..max).step_by(step) { - // let name = gen_name(i as u64); - let full_name = format!("{}@shenjack", i); + let name = gen_name(i as u64); + let full_name = format!("{}@shenjack", name); let namer = name::Namer::new(&full_name); if let Some(namer) = namer { let prop = namer.get_property(); diff --git a/src/name.rs b/src/name.rs index 7655908..787ff6e 100644 --- a/src/name.rs +++ b/src/name.rs @@ -23,6 +23,23 @@ pub struct Namer { impl Namer { pub fn new(raw_name: &String) -> Option { + // name@team + // name + let (name, team) = raw_name.split_once('@').unwrap_or((raw_name, "")); + // len < 256 + if name.len() > 256 { + warn!("Name too long({}): {}", name.len(), name); + return None; + } + if team.len() > 256 { + warn!("Team too long({}): {}", team.len(), team); + return None; + } + Self::new_raw(name.to_string(), team.to_string()) + } + + pub fn new_raw(name: String, team: String) -> Option { + let mut val = [0_u8; 256]; for i in 0..256 { val[i] = i as u8; @@ -32,9 +49,6 @@ impl Namer { let skl_id = [0_u8; 40]; let skl_freq = [0_u8; 40]; - // name@team - // name - let (name, team) = raw_name.split_once('@').unwrap_or((raw_name, "")); // len < 256 if name.len() > 256 { warn!("Name too long({}): {}", name.len(), name);