Skip to content

Commit 68f09fc

Browse files
committed
inline(always) functions called from bootstrap shims
These functions are called thousands of times during bootstrap, so it's better to inline them. Signed-off-by: onur-ozkan <[email protected]>
1 parent 298c746 commit 68f09fc

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

src/bootstrap/src/utils/shared_helpers.rs

+7
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ mod tests;
1818

1919
/// Returns the environment variable which the dynamic library lookup path
2020
/// resides in for this platform.
21+
#[inline(always)]
2122
pub fn dylib_path_var() -> &'static str {
2223
if cfg!(target_os = "windows") {
2324
"PATH"
@@ -34,6 +35,7 @@ pub fn dylib_path_var() -> &'static str {
3435

3536
/// Parses the `dylib_path_var()` environment variable, returning a list of
3637
/// paths that are members of this lookup path.
38+
#[inline(always)]
3739
pub fn dylib_path() -> Vec<std::path::PathBuf> {
3840
let var = match std::env::var_os(dylib_path_var()) {
3941
Some(v) => v,
@@ -44,6 +46,7 @@ pub fn dylib_path() -> Vec<std::path::PathBuf> {
4446

4547
/// Given an executable called `name`, return the filename for the
4648
/// executable for a particular target.
49+
#[inline(always)]
4750
pub fn exe(name: &str, target: &str) -> String {
4851
if target.contains("windows") {
4952
format!("{name}.exe")
@@ -60,6 +63,7 @@ pub fn exe(name: &str, target: &str) -> String {
6063
/// If it was not defined, returns 0 by default.
6164
///
6265
/// Panics if "RUSTC_VERBOSE" is defined with the value that is not an unsigned integer.
66+
#[inline(always)]
6367
pub fn parse_rustc_verbose() -> usize {
6468
match env::var("RUSTC_VERBOSE") {
6569
Ok(s) => usize::from_str(&s).expect("RUSTC_VERBOSE should be an integer"),
@@ -70,6 +74,7 @@ pub fn parse_rustc_verbose() -> usize {
7074
/// Parses the value of the "RUSTC_STAGE" environment variable and returns it as a `String`.
7175
///
7276
/// If "RUSTC_STAGE" was not set, the program will be terminated with 101.
77+
#[inline(always)]
7378
pub fn parse_rustc_stage() -> String {
7479
env::var("RUSTC_STAGE").unwrap_or_else(|_| {
7580
// Don't panic here; it's reasonable to try and run these shims directly. Give a helpful error instead.
@@ -83,6 +88,7 @@ pub fn parse_rustc_stage() -> String {
8388
///
8489
/// Before writing it, replaces user-specific values to create generic dumps for cross-environment
8590
/// comparisons.
91+
#[inline(always)]
8692
pub fn maybe_dump(dump_name: String, cmd: &Command) {
8793
if let Ok(dump_dir) = env::var("DUMP_BOOTSTRAP_SHIMS") {
8894
let dump_file = format!("{dump_dir}/{dump_name}");
@@ -98,6 +104,7 @@ pub fn maybe_dump(dump_name: String, cmd: &Command) {
98104
}
99105

100106
/// Finds `key` and returns its value from the given list of arguments `args`.
107+
#[inline(always)]
101108
pub fn parse_value_from_args<'a>(args: &'a [OsString], key: &str) -> Option<&'a str> {
102109
let mut args = args.iter();
103110
while let Some(arg) = args.next() {

0 commit comments

Comments
 (0)