@@ -13,7 +13,6 @@ use crate::stats::MetricsEnabled;
13
13
use crate :: { ColorPrimaries , MatrixCoefficients , TransferCharacteristics } ;
14
14
use clap:: { CommandFactory , Parser as Clap , Subcommand } ;
15
15
use clap_complete:: { generate, Shell } ;
16
- use once_cell:: sync:: Lazy ;
17
16
use rav1e:: prelude:: * ;
18
17
use scan_fmt:: scan_fmt;
19
18
@@ -22,6 +21,7 @@ use std::fs::File;
22
21
use std:: io;
23
22
use std:: io:: prelude:: * ;
24
23
use std:: path:: PathBuf ;
24
+ use std:: sync:: OnceLock ;
25
25
26
26
pub mod built_info {
27
27
// The file has been placed there by the build script.
@@ -258,29 +258,30 @@ pub struct CliOptions {
258
258
pub command : Option < Commands > ,
259
259
}
260
260
261
+ static VERSION_STR : OnceLock < String > = OnceLock :: new ( ) ;
262
+ static LONG_VERSION_STR : OnceLock < String > = OnceLock :: new ( ) ;
263
+
261
264
fn get_version ( ) -> & ' static str {
262
- static VERSION_STR : Lazy < String > = Lazy :: new ( || {
265
+ VERSION_STR . get_or_init ( || {
263
266
format ! (
264
267
"{} ({})" ,
265
268
rav1e:: version:: full( ) ,
266
269
// We cannot use `built_info::DEBUG` because that tells us if there are debug symbols,
267
270
// not if there are optimizations.
268
271
if cfg!( debug_assertions) { "debug" } else { "release" }
269
272
)
270
- } ) ;
271
- & VERSION_STR
273
+ } )
272
274
}
273
275
274
276
fn get_long_version ( ) -> & ' static str {
275
- static LONG_VERSION_STR : Lazy < String > = Lazy :: new ( || {
277
+ LONG_VERSION_STR . get_or_init ( || {
276
278
let rustflags = env ! ( "CARGO_ENCODED_RUSTFLAGS" ) ;
277
279
let rustflags = if rustflags. trim ( ) . is_empty ( ) {
278
280
"(None)" . to_string ( )
279
281
} else {
280
282
// Replace non-printable ASCII Unit Separator with whitespace
281
283
rustflags. replace ( 0x1F as char , " " )
282
284
} ;
283
-
284
285
format ! (
285
286
"{}\n {} {}\n Compiled CPU Features: {}\n Runtime Assembly Support: {}{}\n Threading: {}\n Unstable Features: {}\n Compiler Flags: {}" ,
286
287
get_version( ) ,
@@ -297,8 +298,7 @@ fn get_long_version() -> &'static str {
297
298
if cfg!( feature = "unstable" ) { "Enabled" } else { "Disabled" } ,
298
299
rustflags
299
300
)
300
- } ) ;
301
- & LONG_VERSION_STR
301
+ } )
302
302
}
303
303
304
304
#[ derive( Subcommand ) ]
@@ -351,8 +351,7 @@ pub struct ParsedCliOptions {
351
351
}
352
352
353
353
#[ cfg( feature = "serialize" ) ]
354
- static HELP_TEXT : once_cell:: sync:: OnceCell < String > =
355
- once_cell:: sync:: OnceCell :: new ( ) ;
354
+ static HELP_TEXT : OnceLock < String > = OnceLock :: new ( ) ;
356
355
357
356
#[ cfg( feature = "serialize" ) ]
358
357
fn build_speed_long_help ( ) -> Option < & ' static str > {
0 commit comments