@@ -14,7 +14,7 @@ use clap::Args;
1414use fluent_syntax:: ast;
1515use fluent_syntax:: ast:: Resource ;
1616use fluent_syntax:: parser;
17- use lazy_static :: lazy_static ;
17+ use once_cell :: sync :: Lazy ;
1818use regex:: Regex ;
1919use walkdir:: DirEntry ;
2020use walkdir:: WalkDir ;
@@ -144,9 +144,7 @@ fn extract_nested_messages_and_terms(
144144 ftl_roots : & [ impl AsRef < str > ] ,
145145 used_ftls : & mut HashSet < String > ,
146146) {
147- lazy_static ! {
148- static ref REFERENCE : Regex = Regex :: new( r"\{\s*-?([-0-9a-z]+)\s*\}" ) . unwrap( ) ;
149- }
147+ static REFERENCE : Lazy < Regex > = Lazy :: new ( || Regex :: new ( r"\{\s*-?([-0-9a-z]+)\s*\}" ) . unwrap ( ) ) ;
150148 for_files_with_ending ( ftl_roots, ".ftl" , |entry| {
151149 let source = fs:: read_to_string ( entry. path ( ) ) . expect ( "file not readable" ) ;
152150 for caps in REFERENCE . captures_iter ( & source) {
@@ -198,11 +196,12 @@ fn entry_use_check(used_ftls: &HashSet<String>) -> impl Fn(&ast::Entry<&str>) ->
198196}
199197
200198fn extract_references_from_file ( refs : & mut HashSet < String > , entry : & DirEntry ) {
201- lazy_static ! {
202- static ref SNAKECASE_TR : Regex = Regex :: new( r"\Wtr\s*\.([0-9a-z_]+)\W" ) . unwrap( ) ;
203- static ref CAMELCASE_TR : Regex = Regex :: new( r"\Wtr2?\.([0-9A-Za-z_]+)\W" ) . unwrap( ) ;
204- static ref DESIGNER_STYLE_TR : Regex = Regex :: new( r"<string>([0-9a-z_]+)</string>" ) . unwrap( ) ;
205- }
199+ static SNAKECASE_TR : Lazy < Regex > =
200+ Lazy :: new ( || Regex :: new ( r"\Wtr\s*\.([0-9a-z_]+)\W" ) . unwrap ( ) ) ;
201+ static CAMELCASE_TR : Lazy < Regex > =
202+ Lazy :: new ( || Regex :: new ( r"\Wtr2?\.([0-9A-Za-z_]+)\W" ) . unwrap ( ) ) ;
203+ static DESIGNER_STYLE_TR : Lazy < Regex > =
204+ Lazy :: new ( || Regex :: new ( r"<string>([0-9a-z_]+)</string>" ) . unwrap ( ) ) ;
206205
207206 let file_name = entry. file_name ( ) . to_str ( ) . expect ( "non-unicode filename" ) ;
208207
0 commit comments