about summary refs log tree commit diff
path: root/tvix/castore/src/blobservice
diff options
context:
space:
mode:
authorFlorian Klink <flokli@flokli.de>2024-10-13T15·31+0300
committerclbot <clbot@tvl.fyi>2024-10-17T21·17+0000
commitcdbdd2d04ecb2675f9c1d7ded7d99ad3a483b6fc (patch)
tree83c68d68e44e3b056213c58e4c9f03e18a1fb860 /tvix/castore/src/blobservice
parenta94414e7ffc5c21874fa0ea6e92aa63fcc55cb7d (diff)
refactor(tvix/castore): remove use of lazy_static r/8823
This is now supported in the standard library via std::sync::LazyLock,
but requires some manual shuffling around of code.

Change-Id: Ia0370ca46cb1c6122a452b1d117160536b632c7e
Reviewed-on: https://cl.tvl.fyi/c/depot/+/12612
Autosubmit: flokli <flokli@flokli.de>
Tested-by: BuildkiteCI
Reviewed-by: tazjin <tazjin@tvl.su>
Diffstat (limited to 'tvix/castore/src/blobservice')
-rw-r--r--tvix/castore/src/blobservice/chunked_reader.rs31
1 files changed, 19 insertions, 12 deletions
diff --git a/tvix/castore/src/blobservice/chunked_reader.rs b/tvix/castore/src/blobservice/chunked_reader.rs
index 6e8355874bca..0e809b300485 100644
--- a/tvix/castore/src/blobservice/chunked_reader.rs
+++ b/tvix/castore/src/blobservice/chunked_reader.rs
@@ -253,14 +253,16 @@ where
 
 #[cfg(test)]
 mod test {
-    use std::{io::SeekFrom, sync::Arc};
+    use std::{
+        io::SeekFrom,
+        sync::{Arc, LazyLock},
+    };
 
     use crate::{
         blobservice::{chunked_reader::ChunkedReader, BlobService, MemoryBlobService},
         B3Digest,
     };
     use hex_literal::hex;
-    use lazy_static::lazy_static;
     use tokio::io::{AsyncReadExt, AsyncSeekExt};
 
     const CHUNK_1: [u8; 2] = hex!("0001");
@@ -269,21 +271,26 @@ mod test {
     const CHUNK_4: [u8; 2] = hex!("0708");
     const CHUNK_5: [u8; 7] = hex!("090a0b0c0d0e0f");
 
-    lazy_static! {
-        // `[ 0 1 ] [ 2 3 4 5 ] [ 6 ] [ 7 8 ] [ 9 10 11 12 13 14 15 ]`
-        pub static ref CHUNK_1_DIGEST: B3Digest = blake3::hash(&CHUNK_1).as_bytes().into();
-        pub static ref CHUNK_2_DIGEST: B3Digest = blake3::hash(&CHUNK_2).as_bytes().into();
-        pub static ref CHUNK_3_DIGEST: B3Digest = blake3::hash(&CHUNK_3).as_bytes().into();
-        pub static ref CHUNK_4_DIGEST: B3Digest = blake3::hash(&CHUNK_4).as_bytes().into();
-        pub static ref CHUNK_5_DIGEST: B3Digest = blake3::hash(&CHUNK_5).as_bytes().into();
-        pub static ref BLOB_1_LIST: [(B3Digest, u64); 5] = [
+    // `[ 0 1 ] [ 2 3 4 5 ] [ 6 ] [ 7 8 ] [ 9 10 11 12 13 14 15 ]`
+    pub static CHUNK_1_DIGEST: LazyLock<B3Digest> =
+        LazyLock::new(|| blake3::hash(&CHUNK_1).as_bytes().into());
+    pub static CHUNK_2_DIGEST: LazyLock<B3Digest> =
+        LazyLock::new(|| blake3::hash(&CHUNK_2).as_bytes().into());
+    pub static CHUNK_3_DIGEST: LazyLock<B3Digest> =
+        LazyLock::new(|| blake3::hash(&CHUNK_3).as_bytes().into());
+    pub static CHUNK_4_DIGEST: LazyLock<B3Digest> =
+        LazyLock::new(|| blake3::hash(&CHUNK_4).as_bytes().into());
+    pub static CHUNK_5_DIGEST: LazyLock<B3Digest> =
+        LazyLock::new(|| blake3::hash(&CHUNK_5).as_bytes().into());
+    pub static BLOB_1_LIST: LazyLock<[(B3Digest, u64); 5]> = LazyLock::new(|| {
+        [
             (CHUNK_1_DIGEST.clone(), 2),
             (CHUNK_2_DIGEST.clone(), 4),
             (CHUNK_3_DIGEST.clone(), 1),
             (CHUNK_4_DIGEST.clone(), 2),
             (CHUNK_5_DIGEST.clone(), 7),
-        ];
-    }
+        ]
+    });
 
     use super::ChunkedBlob;