From 55cc7c54a39b4308520ba8e5ae60850ebabfa1e1 Mon Sep 17 00:00:00 2001 From: Dirkjan Ochtman Date: Thu, 4 Feb 2021 10:17:11 +0100 Subject: [PATCH] Use powi() instead of powf() for performance --- src/lib.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/lib.rs b/src/lib.rs index 7828486..68e40e2 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -56,7 +56,7 @@ impl Segmenter { Some(p) => p / self.total, // Penalize words not found in the unigrams according // to their length, a crucial heuristic. - None => 10.0 / (self.total * 10.0f64.powf(word.len() as f64)), + None => 10.0 / (self.total * 10.0f64.powi(word.len() as i32)), } }