mirror of
https://github.com/ntex-rs/ntex.git
synced 2025-04-04 21:37:58 +03:00
reserve space for put_slice
This commit is contained in:
parent
fa6cd65cfc
commit
53e9487357
3 changed files with 10 additions and 4 deletions
|
@ -1,5 +1,9 @@
|
||||||
# Changes
|
# Changes
|
||||||
|
|
||||||
|
## 0.1.2 (2021-06-27)
|
||||||
|
|
||||||
|
* Reserve space for put_slice
|
||||||
|
|
||||||
## 0.1.1 (2021-06-27)
|
## 0.1.1 (2021-06-27)
|
||||||
|
|
||||||
* Add `ByteString::as_slice()` method
|
* Add `ByteString::as_slice()` method
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
[package]
|
[package]
|
||||||
name = "ntex-bytes"
|
name = "ntex-bytes"
|
||||||
version = "0.1.1"
|
version = "0.1.2"
|
||||||
license = "MIT"
|
license = "MIT"
|
||||||
authors = ["Carl Lerche <me@carllerche.com>"]
|
authors = ["Carl Lerche <me@carllerche.com>"]
|
||||||
description = "Types and traits for working with bytes (bytes crate fork)"
|
description = "Types and traits for working with bytes (bytes crate fork)"
|
||||||
|
@ -15,6 +15,8 @@ edition = "2018"
|
||||||
serde = "1.0"
|
serde = "1.0"
|
||||||
bytes = "1.0.1"
|
bytes = "1.0.1"
|
||||||
|
|
||||||
|
backtrace = "*"
|
||||||
|
|
||||||
[dev-dependencies]
|
[dev-dependencies]
|
||||||
serde_test = "1.0"
|
serde_test = "1.0"
|
||||||
serde_json = "1.0"
|
serde_json = "1.0"
|
||||||
|
|
|
@ -1566,7 +1566,6 @@ impl BytesMut {
|
||||||
/// ```
|
/// ```
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn extend_from_slice(&mut self, extend: &[u8]) {
|
pub fn extend_from_slice(&mut self, extend: &[u8]) {
|
||||||
self.reserve(extend.len());
|
|
||||||
self.put_slice(extend);
|
self.put_slice(extend);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1671,9 +1670,8 @@ impl BufMut for BytesMut {
|
||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
fn put_slice(&mut self, src: &[u8]) {
|
fn put_slice(&mut self, src: &[u8]) {
|
||||||
assert!(self.remaining_mut() >= src.len());
|
|
||||||
|
|
||||||
let len = src.len();
|
let len = src.len();
|
||||||
|
self.reserve(len);
|
||||||
|
|
||||||
unsafe {
|
unsafe {
|
||||||
ptr::copy_nonoverlapping(
|
ptr::copy_nonoverlapping(
|
||||||
|
@ -1687,11 +1685,13 @@ impl BufMut for BytesMut {
|
||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
fn put_u8(&mut self, n: u8) {
|
fn put_u8(&mut self, n: u8) {
|
||||||
|
self.reserve(1);
|
||||||
self.inner.put_u8(n);
|
self.inner.put_u8(n);
|
||||||
}
|
}
|
||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
fn put_i8(&mut self, n: i8) {
|
fn put_i8(&mut self, n: i8) {
|
||||||
|
self.reserve(1);
|
||||||
self.put_u8(n as u8);
|
self.put_u8(n as u8);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue