From 7e1feeb917a5c0cafe5c8af9ff6586551a40d691 Mon Sep 17 00:00:00 2001 From: "Shane F. Carr" Date: Wed, 15 Sep 2021 23:34:44 -0500 Subject: [PATCH] WIP: Migrate BlobProvider to ZeroMap --- Cargo.lock | 1 + provider/blob/Cargo.toml | 1 + provider/blob/examples/{simple.rs => simple_static.rs} | 0 provider/blob/src/blob_schema.rs | 6 ++++-- provider/blob/src/static_data_provider.rs | 1 - 5 files changed, 6 insertions(+), 3 deletions(-) rename provider/blob/examples/{simple.rs => simple_static.rs} (100%) diff --git a/Cargo.lock b/Cargo.lock index 9d0319aa02a..a93b017c311 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1210,6 +1210,7 @@ dependencies = [ "postcard", "serde", "writeable", + "zerovec", ] [[package]] diff --git a/provider/blob/Cargo.toml b/provider/blob/Cargo.toml index 0005c880c58..eb7cfd436e3 100644 --- a/provider/blob/Cargo.toml +++ b/provider/blob/Cargo.toml @@ -33,6 +33,7 @@ serde = { version = "1.0", default-features = false, features = ["alloc"] } postcard = { version = "0.7.0" } erased-serde = { version = "0.3", default-features = false, features = ["alloc"] } litemap = { version = "0.2.0", path = "../../utils/litemap/", features = ["serde"] } +zerovec = { version = "0.3", path = "../../utils/zerovec", features = ["serde"] } writeable = { path = "../../utils/writeable" } # For the export feature diff --git a/provider/blob/examples/simple.rs b/provider/blob/examples/simple_static.rs similarity index 100% rename from provider/blob/examples/simple.rs rename to provider/blob/examples/simple_static.rs diff --git a/provider/blob/src/blob_schema.rs b/provider/blob/src/blob_schema.rs index f83686b1a3f..e78d1599b1b 100644 --- a/provider/blob/src/blob_schema.rs +++ b/provider/blob/src/blob_schema.rs @@ -3,6 +3,9 @@ // (online at: https://github.com/unicode-org/icu4x/blob/main/LICENSE ). use litemap::LiteMap; +use zerovec::*; +use alloc::string::String; +use alloc::vec::Vec; /// A versioned Serde schema for ICU4X data blobs. #[derive(serde::Serialize, serde::Deserialize)] @@ -14,7 +17,6 @@ pub enum BlobSchema<'data> { /// Version 1 of the ICU4X data blob schema. #[derive(serde::Serialize, serde::Deserialize)] pub struct BlobSchemaV1<'data> { - // TODO(#829): Use ZeroMap instead of LiteMap. #[serde(borrow)] - pub resources: LiteMap<&'data str, &'data [u8]>, + pub resources: ZeroMap<'data, String, Vec>, } diff --git a/provider/blob/src/static_data_provider.rs b/provider/blob/src/static_data_provider.rs index 0cca0a046a0..0be8c0bebc7 100644 --- a/provider/blob/src/static_data_provider.rs +++ b/provider/blob/src/static_data_provider.rs @@ -68,7 +68,6 @@ impl StaticDataProvider { blob.resources .get(&*path) .ok_or(DataError::MissingResourceKey(req.resource_path.key)) - .map(|v| *v) } }