Skip to content

Commit

Permalink
use std lazy lock
Browse files Browse the repository at this point in the history
  • Loading branch information
xx01cyx committed Nov 15, 2024
1 parent 80f46f7 commit a607c17
Show file tree
Hide file tree
Showing 3 changed files with 2 additions and 6 deletions.
1 change: 0 additions & 1 deletion optd-cost-model/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 0 additions & 1 deletion optd-cost-model/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ datafusion-expr = "32.0.0"
ordered-float = "4.0"
chrono = "0.4"
itertools = "0.13"
once_cell = "1.20"

[dev-dependencies]
crossbeam = "0.8"
Expand Down
6 changes: 2 additions & 4 deletions optd-cost-model/src/stats/arith_encoder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,7 @@
//! Non-alpha-numeric characters are relegated to the end of the encoded value,
//! rendering them indistinguishable from one another in this context.
use std::collections::HashMap;

use once_cell::sync::Lazy;
use std::{collections::HashMap, sync::LazyLock};

// The alphanumerical ordering.
const ALPHANUMERIC_ORDER: [char; 95] = [
Expand All @@ -22,7 +20,7 @@ const ALPHANUMERIC_ORDER: [char; 95] = [

const PMF: f64 = 1.0 / (ALPHANUMERIC_ORDER.len() as f64);

static CDF: Lazy<HashMap<char, f64>> = Lazy::new(|| {
static CDF: LazyLock<HashMap<char, f64>> = LazyLock::new(|| {
let length = ALPHANUMERIC_ORDER.len() + 1; // To account for non-alpha-numeric characters.
let mut cdf = HashMap::with_capacity(length);
for (index, &char) in ALPHANUMERIC_ORDER.iter().enumerate() {
Expand Down

0 comments on commit a607c17

Please sign in to comment.