Skip to content

Commit

Permalink
dedupe against script root
Browse files Browse the repository at this point in the history
  • Loading branch information
robertbastian committed Jan 9, 2025
1 parent c72abf0 commit 1e46e4f
Show file tree
Hide file tree
Showing 24 changed files with 1,175 additions and 1,008 deletions.
2 changes: 2 additions & 0 deletions components/datetime/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@ serde = [
"dep:serde",
"icu_calendar/serde",
"icu_decimal/serde",
"icu_locale_core/serde",
"icu_pattern/serde",
"icu_plurals/serde",
"icu_provider/serde",
Expand All @@ -89,6 +90,7 @@ datagen = [
"dep:databake",
"dep:litemap",
"icu_calendar/datagen",
"icu_locale_core/databake",
"icu_pattern/databake",
"icu_plurals/datagen",
"icu_timezone/datagen",
Expand Down
29 changes: 25 additions & 4 deletions components/datetime/src/pattern/names.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1912,14 +1912,35 @@ impl<FSet: DateTimeNamesMarker> RawDateTimeNames<FSet> {
id: DataIdentifierBorrowed::for_locale(&locale),
..Default::default()
};
self.locations_root
.load_put(provider, Default::default(), variables)
.map_err(|e| MaybePayloadError::into_load_error(e, error_field))?
.map_err(|e| PatternLoadError::Data(e, error_field))?;
self.locations
.load_put(provider, req, variables)
.map_err(|e| MaybePayloadError::into_load_error(e, error_field))?
.map_err(|e| PatternLoadError::Data(e, error_field))?;

#[allow(clippy::unwrap_used)] // we just loaded it
let (dedupe_language, dedupe_script) = self
.locations
.get()
.inner
.get_with_variables(variables)
.unwrap()
.dedupe_target;
let dedupe_locale = DataLocale {
language: dedupe_language,
script: dedupe_script,
..Default::default()
};
self.locations_root
.load_put(
provider,
DataRequest {
id: DataIdentifierBorrowed::for_locale(&dedupe_locale),
..Default::default()
},
variables,
)
.map_err(|e| MaybePayloadError::into_load_error(e, error_field))?
.map_err(|e| PatternLoadError::Data(e, error_field))?;
Ok(())
}

Expand Down
3 changes: 3 additions & 0 deletions components/datetime/src/provider/time_zones.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
//! Data provider structs for time zones.
use alloc::borrow::Cow;
use icu_locale_core::subtags::{Language, Script};
use icu_pattern::{DoublePlaceholderPattern, SinglePlaceholderPattern};
use icu_provider::prelude::*;
use tinystr::TinyAsciiStr;
Expand Down Expand Up @@ -82,6 +83,8 @@ pub struct TimeZoneEssentialsV1<'data> {
#[cfg_attr(feature = "serde", derive(serde::Deserialize))]
#[yoke(prove_covariance_manually)]
pub struct LocationsV1<'data> {
/// The data struct against which the location names are deduplicated.
pub dedupe_target: (Language, Option<Script>),
/// Per-zone location display name
#[cfg_attr(feature = "serde", serde(borrow))]
pub locations: ZeroMap<'data, TimeZoneBcp47Id, str>,
Expand Down
565 changes: 379 additions & 186 deletions provider/data/datetime/data/locations_v1_marker.rs.data

Large diffs are not rendered by default.

411 changes: 205 additions & 206 deletions provider/data/datetime/fingerprints.csv

Large diffs are not rendered by default.

4 changes: 4 additions & 0 deletions provider/source/data/debug/time_zone/locations@1/ar-EG.json

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

4 changes: 4 additions & 0 deletions provider/source/data/debug/time_zone/locations@1/ar.json

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

4 changes: 4 additions & 0 deletions provider/source/data/debug/time_zone/locations@1/bn.json

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

11 changes: 11 additions & 0 deletions provider/source/data/debug/time_zone/locations@1/ccp.json

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

33 changes: 5 additions & 28 deletions provider/source/data/debug/time_zone/locations@1/en-001.json

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

33 changes: 5 additions & 28 deletions provider/source/data/debug/time_zone/locations@1/en-ZA.json

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

Loading

0 comments on commit 1e46e4f

Please sign in to comment.