@@ -10,6 +10,7 @@ use crate::{CollationHanDatabase, CoverageLevel};
10
10
use elsa:: sync:: FrozenMap ;
11
11
use icu_provider:: datagen:: IterableDataProvider ;
12
12
use icu_provider:: prelude:: * ;
13
+ use std:: collections:: HashSet ;
13
14
use std:: fmt:: Debug ;
14
15
use std:: path:: PathBuf ;
15
16
use std:: sync:: Arc ;
@@ -80,7 +81,7 @@ impl DatagenProvider {
80
81
icuexport_dictionary_fallback : None ,
81
82
#[ cfg( feature = "legacy_api" ) ]
82
83
collations : Default :: default ( ) ,
83
- supported_locales_cache_vec : Default :: default ( ) ,
84
+ supported_locales_cache : Default :: default ( ) ,
84
85
} ,
85
86
}
86
87
}
@@ -262,15 +263,20 @@ impl DatagenProvider {
262
263
self . cldr ( ) ?. locales ( levels)
263
264
}
264
265
265
- pub ( crate ) fn supported_locales_vec < M > ( & self ) -> Result < & Vec < DataLocale > , DataError >
266
+ pub ( crate ) fn supported_locales_vec < M > ( & self ) -> Result < & HashSet < DataLocale > , DataError >
266
267
where
267
268
M : KeyedDataMarker ,
268
269
Self : IterableDataProviderInternal < M > ,
269
270
{
270
271
#[ allow( deprecated) ] // SourceData
271
272
self . source
272
- . supported_locales_cache_vec
273
- . insert_with ( M :: KEY , || Box :: from ( self . supported_locales_impl ( ) ) )
273
+ . supported_locales_cache
274
+ . insert_with ( M :: KEY , || {
275
+ Box :: new (
276
+ self . supported_locales_impl ( )
277
+ . map ( |v| v. into_iter ( ) . collect ( ) ) ,
278
+ )
279
+ } )
274
280
. as_ref ( )
275
281
. map_err ( |e| * e)
276
282
}
@@ -322,8 +328,8 @@ pub struct SourceData {
322
328
pub ( crate ) icuexport_dictionary_fallback : Option < Arc < SerdeCache > > ,
323
329
#[ cfg( feature = "legacy_api" ) ]
324
330
pub ( crate ) collations : Vec < String > ,
325
- pub ( crate ) supported_locales_cache_vec :
326
- Arc < FrozenMap < DataKey , Box < Result < Vec < DataLocale > , DataError > > > > ,
331
+ pub ( crate ) supported_locales_cache :
332
+ Arc < FrozenMap < DataKey , Box < Result < HashSet < DataLocale > , DataError > > > > ,
327
333
}
328
334
329
335
#[ cfg( feature = "legacy_api" ) ]
@@ -513,7 +519,8 @@ where
513
519
DatagenProvider : IterableDataProviderInternal < M > ,
514
520
{
515
521
fn supported_locales ( & self ) -> Result < Vec < DataLocale > , DataError > {
516
- self . supported_locales_vec ( ) . cloned ( )
522
+ self . supported_locales_vec ( )
523
+ . map ( |v| v. iter ( ) . cloned ( ) . collect ( ) )
517
524
}
518
525
519
526
fn supports_locale ( & self , locale : & DataLocale ) -> Result < bool , DataError > {
0 commit comments