Skip to content

Commit 84438fa

Browse files
committed
Preliminary for dropping releae-fast profile
1 parent a06760e commit 84438fa

1 file changed

Lines changed: 12 additions & 5 deletions

File tree

src/uucore/src/lib/mods/error.rs

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@
5252
//! * Using [`ExitCode`] is not recommended but can be useful for converting utils to use
5353
//! [`UResult`].
5454
55-
// spell-checker:ignore uioerror rustdoc
55+
// spell-checker:ignore codegen-units uioerror rustdoc
5656

5757
use std::{
5858
cell::Cell,
@@ -394,13 +394,20 @@ impl UIoError {
394394
#[allow(clippy::new_ret_no_self)]
395395
/// Create a new `UIoError` with a given exit code and message.
396396
pub fn new<S: Into<String>>(kind: std::io::ErrorKind, context: S) -> Box<dyn UError> {
397-
Box::new(Self {
398-
context: Some(context.into()),
399-
inner: kind.into(),
400-
})
397+
cold_io_error(kind, context.into())
401398
}
402399
}
403400

401+
// avoid performance regression with codegen-units=1
402+
#[cold]
403+
#[inline(never)]
404+
fn cold_io_error(kind: std::io::ErrorKind, context: String) -> Box<dyn UError> {
405+
Box::new(UIoError {
406+
context: Some(context),
407+
inner: kind.into(),
408+
})
409+
}
410+
404411
impl UError for UIoError {}
405412

406413
impl Error for UIoError {}

0 commit comments

Comments
 (0)