Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

std: A few code size optimizations #12616

Merged
merged 4 commits into from
Feb 28, 2014
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/libnative/io/process.rs
Original file line number Diff line number Diff line change
Expand Up @@ -470,7 +470,7 @@ fn spawn_process_os(config: p::ProcessConfig,
Err(e) => {
assert!(e.kind == io::BrokenPipe ||
e.kind == io::EndOfFile,
"unexpected error: {:?}", e);
"unexpected error: {}", e);
Ok(SpawnProcessResult {
pid: pid,
handle: ptr::null()
Expand Down Expand Up @@ -744,7 +744,7 @@ fn waitpid(pid: pid_t) -> p::ProcessExit {

let mut status = 0 as c_int;
match retry(|| unsafe { wait::waitpid(pid, &mut status, 0) }) {
-1 => fail!("unknown waitpid error: {:?}", super::last_error()),
-1 => fail!("unknown waitpid error: {}", super::last_error()),
_ => {
if imp::WIFEXITED(status) {
p::ExitStatus(imp::WEXITSTATUS(status) as int)
Expand Down
9 changes: 8 additions & 1 deletion src/libstd/macros.rs
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,14 @@ macro_rules! fail(
// function to pass to format_args!, *and* we need the
// file and line numbers right here; so an inner bare fn
// is our only choice.
#[inline]
//
// LLVM doesn't tend to inline this, presumably because begin_unwind_fmt
// is #[cold] and #[inline(never)] and because this is flagged as cold
// as returning !. We really do want this to be inlined, however,
// because it's just a tiny wrapper. Small wins (156K to 149K in size)
// were seen when forcing this to be inlined, and that number just goes
// up with the number of calls to fail!()
#[inline(always)]
fn run_fmt(fmt: &::std::fmt::Arguments) -> ! {
::std::rt::begin_unwind_fmt(fmt, file!(), line!())
}
Expand Down
10 changes: 5 additions & 5 deletions src/libstd/num/strconv.rs
Original file line number Diff line number Diff line change
Expand Up @@ -532,19 +532,19 @@ pub fn from_str_bytes_common<T:NumCast+Zero+One+Eq+Ord+Div<T,T>+
) -> Option<T> {
match exponent {
ExpDec if radix >= DIGIT_E_RADIX // decimal exponent 'e'
=> fail!("from_str_bytes_common: radix {:?} incompatible with \
=> fail!("from_str_bytes_common: radix {} incompatible with \
use of 'e' as decimal exponent", radix),
ExpBin if radix >= DIGIT_P_RADIX // binary exponent 'p'
=> fail!("from_str_bytes_common: radix {:?} incompatible with \
=> fail!("from_str_bytes_common: radix {} incompatible with \
use of 'p' as binary exponent", radix),
_ if special && radix >= DIGIT_I_RADIX // first digit of 'inf'
=> fail!("from_str_bytes_common: radix {:?} incompatible with \
=> fail!("from_str_bytes_common: radix {} incompatible with \
special values 'inf' and 'NaN'", radix),
_ if (radix as int) < 2
=> fail!("from_str_bytes_common: radix {:?} to low, \
=> fail!("from_str_bytes_common: radix {} to low, \
must lie in the range [2, 36]", radix),
_ if (radix as int) > 36
=> fail!("from_str_bytes_common: radix {:?} to high, \
=> fail!("from_str_bytes_common: radix {} to high, \
must lie in the range [2, 36]", radix),
_ => ()
}
Expand Down
4 changes: 2 additions & 2 deletions src/libstd/rt/crate_map.rs
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ fn version(crate_map: &CrateMap) -> i32 {

fn do_iter_crate_map<'a>(
crate_map: &'a CrateMap<'a>,
f: |&ModEntry|,
f: |&'a ModEntry<'a>|,
visited: &mut ~[*CrateMap<'a>]) {
let raw = crate_map as *CrateMap<'a>;
if visited.bsearch(|a| (*a as uint).cmp(&(raw as uint))).is_some() {
Expand All @@ -149,7 +149,7 @@ fn do_iter_crate_map<'a>(
}

/// Iterates recursively over `crate_map` and all child crate maps
pub fn iter_crate_map<'a>(crate_map: &'a CrateMap<'a>, f: |&ModEntry|) {
pub fn iter_crate_map<'a>(crate_map: &'a CrateMap<'a>, f: |&'a ModEntry<'a>|) {
let mut v = ~[];
do_iter_crate_map(crate_map, f, &mut v);
}
Expand Down
Loading