From 4465b2fbf3487e8f45e2eee4da187776574febec Mon Sep 17 00:00:00 2001 From: Nicholas Nethercote Date: Thu, 3 May 2018 17:14:04 +1000 Subject: [PATCH] Inline `char_at()` and `record_width`. Because `bump()` is hot. --- src/libsyntax/str.rs | 1 + src/libsyntax_pos/lib.rs | 1 + 2 files changed, 2 insertions(+) diff --git a/src/libsyntax/str.rs b/src/libsyntax/str.rs index d0f47629b10e..281861918fd8 100644 --- a/src/libsyntax/str.rs +++ b/src/libsyntax/str.rs @@ -8,6 +8,7 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. +#[inline] pub fn char_at(s: &str, byte: usize) -> char { s[byte..].chars().next().unwrap() } diff --git a/src/libsyntax_pos/lib.rs b/src/libsyntax_pos/lib.rs index d30d3d78ca54..2bab958dceda 100644 --- a/src/libsyntax_pos/lib.rs +++ b/src/libsyntax_pos/lib.rs @@ -1047,6 +1047,7 @@ pub fn record_multibyte_char(&self, pos: BytePos, bytes: usize) { self.multibyte_chars.borrow_mut().push(mbc); } + #[inline] pub fn record_width(&self, pos: BytePos, ch: char) { let width = match ch { '\t' =>