Compare commits

...

2 Commits

Author SHA1 Message Date
421ac1a566
update test 2024-06-24 09:18:49 +08:00
5e9a79f868
what 2024-06-24 09:13:43 +08:00

View File

@ -542,26 +542,77 @@ impl Namer {
}
}
}
// match last {
// -1 => (),
// 14 => unsafe {
// // 下面这一行应该只在 14 != 0 时运行
// // 我试试优化成 *[14] / [14] 看看咋样
// *self.skl_freq.get_unchecked_mut(14) += min(
// min(*self.name_base.get_unchecked(60), *self.name_base.get_unchecked(61)),
// *self.skl_freq.get_unchecked(14),
// ) * self.skl_freq.get_unchecked(14)
// / self.skl_freq.get_unchecked(14);
// },
// 15 => unsafe {
// if self.skl_freq.get_unchecked(15) != 0 { *self.skl_freq.get_unchecked_mut(15) += min(
// min(*self.name_base.get_unchecked(62), *self.name_base.get_unchecked(63)),
// *self.skl_freq.get_unchecked(15))}
// );
// },
// _ => unsafe {
// *self.skl_freq.get_unchecked_mut(last as usize) <<= 1;
// },
// }
match last {
-1 => (),
14 => unsafe {
// 下面这一行应该只在 14 != 0 时运行
// 我试试优化成 *[14] / [14] 看看咋样
-1 => unsafe {
// 判断 14, 15 去
if *self.skl_freq.get_unchecked(14) != 0 {
*self.skl_freq.get_unchecked_mut(14) += min(
min(*self.name_base.get_unchecked(60), *self.name_base.get_unchecked(61)),
*self.skl_freq.get_unchecked(14),
) * self.skl_freq.get_unchecked(14)
/ self.skl_freq.get_unchecked(14);
},
15 => unsafe {
)
}
if *self.skl_freq.get_unchecked(15) != 0 {
*self.skl_freq.get_unchecked_mut(15) += min(
min(*self.name_base.get_unchecked(62), *self.name_base.get_unchecked(63)),
*self.skl_freq.get_unchecked(15),
) * self.skl_freq.get_unchecked(15)
/ self.skl_freq.get_unchecked(15);
)
}
},
_ => unsafe {
*self.skl_freq.get_unchecked_mut(last as usize) <<= 1;
14 => unsafe {
// 判断 15
*self.skl_freq.get_unchecked_mut(14) <<= 1;
if *self.skl_freq.get_unchecked(15) != 0 {
*self.skl_freq.get_unchecked_mut(15) += min(
min(*self.name_base.get_unchecked(62), *self.name_base.get_unchecked(63)),
*self.skl_freq.get_unchecked(15),
)
}
},
15 => unsafe {
// 判断 14
*self.skl_freq.get_unchecked_mut(15) <<= 1;
if *self.skl_freq.get_unchecked(14) != 0 {
*self.skl_freq.get_unchecked_mut(14) += min(
min(*self.name_base.get_unchecked(60), *self.name_base.get_unchecked(61)),
*self.skl_freq.get_unchecked(14),
)
}
},
x => unsafe {
*self.skl_freq.get_unchecked_mut(x as usize) <<= 1;
if *self.skl_freq.get_unchecked(14) != 0 {
*self.skl_freq.get_unchecked_mut(14) += min(
min(*self.name_base.get_unchecked(60), *self.name_base.get_unchecked(61)),
*self.skl_freq.get_unchecked(14),
)
}
if *self.skl_freq.get_unchecked(15) != 0 {
*self.skl_freq.get_unchecked_mut(15) += min(
min(*self.name_base.get_unchecked(62), *self.name_base.get_unchecked(63)),
*self.skl_freq.get_unchecked(15),
)
}
},
}
}
@ -768,10 +819,10 @@ mod test {
fn update_name_test() {
// 先创建一个正常的 namer
// 然后更新名字
let team = TeamNamer::new_unchecked("x");
let team = TeamNamer::new_unchecked("shenjack");
let mut namer = Namer::new_from_team_namer_unchecked(&team, "x");
let update_name = "k";
let update_name = "一一一丑堀㴁";
namer.replace_name(&team, update_name);
let mut none_update_name = Namer::new_from_team_namer_unchecked(&team, update_name);