Add new feature (perf-inline)
This commit is contained in:
parent
bc4bb47082
commit
dd4d31a48c
|
@ -12,6 +12,10 @@ license = "MIT"
|
||||||
workspace = ".."
|
workspace = ".."
|
||||||
edition = "2018"
|
edition = "2018"
|
||||||
|
|
||||||
|
[features]
|
||||||
|
default = ["perf-inline"]
|
||||||
|
perf-inline = []
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
ryu = "1.0.4"
|
ryu = "1.0.4"
|
||||||
|
|
||||||
|
|
|
@ -38,7 +38,7 @@ impl Buffer {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[inline]
|
#[cfg_attr(feature = "perf-inline", inline)]
|
||||||
pub fn with_capacity(n: usize) -> Buffer {
|
pub fn with_capacity(n: usize) -> Buffer {
|
||||||
unsafe {
|
unsafe {
|
||||||
if n == 0 {
|
if n == 0 {
|
||||||
|
@ -133,7 +133,7 @@ impl Buffer {
|
||||||
self.push_str(data.encode_utf8(&mut buf));
|
self.push_str(data.encode_utf8(&mut buf));
|
||||||
}
|
}
|
||||||
|
|
||||||
#[inline]
|
#[cfg_attr(feature = "perf-inline", inline)]
|
||||||
fn reserve_internal(&mut self, size: usize) {
|
fn reserve_internal(&mut self, size: usize) {
|
||||||
unsafe {
|
unsafe {
|
||||||
let new_capacity = std::cmp::max(self.capacity * 2, self.len + size);
|
let new_capacity = std::cmp::max(self.capacity * 2, self.len + size);
|
||||||
|
@ -142,7 +142,7 @@ impl Buffer {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[inline]
|
#[cfg_attr(feature = "perf-inline", inline)]
|
||||||
unsafe fn realloc(&self, cap: usize) -> *mut u8 {
|
unsafe fn realloc(&self, cap: usize) -> *mut u8 {
|
||||||
let data = if unlikely!(self.capacity == 0) {
|
let data = if unlikely!(self.capacity == 0) {
|
||||||
let new_layout = Layout::from_size_align_unchecked(cap, 1);
|
let new_layout = Layout::from_size_align_unchecked(cap, 1);
|
||||||
|
|
|
@ -72,7 +72,7 @@ pub unsafe fn escape(feed: &str, buffer: &mut Buffer) {
|
||||||
}
|
}
|
||||||
|
|
||||||
#[target_feature(enable = "sse2")]
|
#[target_feature(enable = "sse2")]
|
||||||
#[inline]
|
#[cfg_attr(feature = "perf-inline", inline)]
|
||||||
pub unsafe fn escape_aligned(
|
pub unsafe fn escape_aligned(
|
||||||
buffer: &mut Buffer,
|
buffer: &mut Buffer,
|
||||||
mut start_ptr: *const u8,
|
mut start_ptr: *const u8,
|
||||||
|
|
Loading…
Reference in New Issue