This commit is contained in:
shenjack 2024-02-29 00:36:28 +08:00
parent c35818f048
commit eb892dccad
Signed by: shenjack
GPG Key ID: 7B1134A979775551
3 changed files with 24 additions and 6 deletions

View File

@ -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

View File

@ -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();

View File

@ -23,6 +23,23 @@ pub struct Namer {
impl Namer {
pub fn new(raw_name: &String) -> Option<Self> {
// 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<Self> {
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);