Brad Dunbar and GitHub
7968f6f83d
Remove redundant reserve call ( #674 )
2024-03-04 09:04:40 +01:00
Brad Dunbar and GitHub
c5fae00c76
copy_to_bytes: Add panic section to docs ( #676 )
...
Fixes #454 .
2024-03-03 22:59:30 +09:00
Brad Dunbar and GitHub
99584cc10d
Use Iterator from the prelude ( #673 )
...
CI is [failing][failure] due to unused_imports because Iterator is
already in the prelude. Removing it fixes things up.
[failure]: https://github.com/tokio-rs/bytes/actions/runs/8034858583/job/21946873895
2024-03-03 00:40:17 +09:00
Brad Dunbar and GitHub
46289278f5
Refactor split_at/split_to ( #663 )
...
* set len a little more concisely
* inline set_end
* remove kind assertions
* remove a duplicate assertion
* remove redundant assertion and min
* rename set_start to advance_unchecked
2024-02-23 14:22:58 -08:00
Brad Dunbar and GitHub
1bcd2129d1
get_vec_pos: use &self instead of &mut self ( #670 )
...
I can't see any reason that get_vec_pos needs a &mut self.
2024-02-06 17:34:30 -05:00
Brad Dunbar and GitHub
f586ffc525
set_vec_pos does not need a second parameter ( #672 )
...
The second argument to `set_vec_pos` always contains the value of
`self.data`. Let's just use `self.data` and remove the second parameter
altogether.
2024-02-06 11:03:37 -08:00
Brad Dunbar and GitHub
c6972d6132
Calculate original capacity only if necessary ( #666 )
...
We don't need the original capacity if the shared data is unique, so
let's not calculate it until after that check.
2024-02-06 10:46:49 -08:00
Brad Dunbar and GitHub
47e83056f2
Use sub instead of offset ( #668 )
...
We're always subtracting here, and we already have a usize, so `sub`
seems like a more appropriate usage to me.
2024-02-06 10:41:44 -08:00
Brad Dunbar and GitHub
8bcac21cb4
Restore commented tests ( #665 )
...
These seem to have been commented by accident in #298 , and are still
passing.
2024-02-06 10:17:01 -08:00
Brad Dunbar and GitHub
d2e7abdb29
refactor: make parameter mut in From<Vec> ( #667 )
...
Instead of re-declaring `vec`, we can just use a mut parameter.
2024-01-31 09:41:23 -05:00
Brad Dunbar and GitHub
e24587dd61
Remove unreachable else branch ( #661 )
2024-01-28 15:30:30 +03:30
Brad Dunbar and GitHub
9257a6ea08
Remove an unnecessary else branch ( #662 )
2024-01-28 14:20:56 +03:30
Brad Dunbar and GitHub
0ba3b4c4cd
Remove unnecessary namespace qualifier ( #660 )
2024-01-28 14:07:11 +03:30
Cyborus04 and GitHub
0864aea970
add Bytes::is_unique ( #643 )
2024-01-19 23:59:30 +01:00
Brad Dunbar and GitHub
abb4a2e66c
BytesMut: Assert alignment of Shared ( #652 )
...
Back in #362 , an assertion was added to ensure that the alignment of
bytes::Shared is even so we can use the least significant bit as a flag.
bytes_mut::Shared uses the same technique but has no such assertion so
I've added one here.
2024-01-19 11:08:27 +01:00
Taiki Endo and GitHub
09214ba51b
Update CI config ( #650 )
2024-01-08 01:11:02 +09:00
Taiki Endo and GitHub
fbc64bcc67
Update loom to 0.7 ( #651 )
2024-01-08 01:10:48 +09:00
Alice Ryhl and GitHub
3bf6583b5c
readme: add security policy ( #649 )
2024-01-03 17:22:39 +01:00
Brad Dunbar and GitHub
dbbdb63d76
Use self. instead of Self:: ( #642 )
...
I was a little confused about these calls using `Self::` instead of
`self.` here. Is there a reason to use the former instead of the latter?
2023-12-28 14:20:13 +09:00
Luca Bruno and GitHub
f73c6c8e85
Simplify UninitSlice::as_uninit_slice_mut() logic ( #644 )
...
This reworks `UninitSlice::as_uninit_slice_mut()` using equivalent
simpler logic.
2023-12-28 14:17:53 +09:00
Gabriel Goller and GitHub
72cbb92e0e
docs: fix broken links ( #639 )
...
Fixed a few broken links and converted a lot of them from the
html-link to intra-doc links.
2023-11-16 06:24:21 -05:00
bde8c50703
docs: typo fix ( #637 )
...
Co-authored-by: Daniel Bauman <[email protected] >
2023-10-19 21:50:24 +02:00
Alice Ryhl and GitHub
fd9243f9e2
Various cleanup ( #635 )
2023-10-02 15:40:02 +02:00
mxsm and GitHub
a4e16a552b
docs: fix some spelling mistakes ( #633 )
2023-09-25 10:47:02 +02:00
Lucas Kent and GitHub
a14ef4617c
Move comment to correct constant ( #629 )
2023-09-11 11:12:11 +02:00
Alice Ryhl and GitHub
bd9c164cb6
doc: fix changelog typo ( #628 )
2023-09-07 14:10:55 +02:00
Alice Ryhl and GitHub
74e6e200fd
chore: prepare bytes v1.5.0 ( #627 )
v1.5.0
2023-09-07 10:52:15 +02:00
Michal Nazarewicz and GitHub
64c4fa2867
Rename UninitSlice constructors for consistency with ReadBuf ( #599 )
...
tokio::io::ReadBuf uses names `new` and `uninit` for its constructors.
For consistency with that, rename recently introduced UninitSlice
constructors to match those names.
2023-06-20 10:19:56 +02:00
Taiki Endo and GitHub
c7756c3e59
Fix CI failure ( #616 )
2023-06-05 01:04:59 +09:00
Michal Nazarewicz and GitHub
b29112ce44
Implement BufMut for &mut [MaybeUninit<u8>] ( #597 )
2023-02-10 10:28:24 +01:00
Michal Nazarewicz and GitHub
99a27542a0
Add a safe way to create UninitSlice from slices ( #598 )
...
Introduce UninitSlice::from_slice and UninitSlice::from_uninit_slice
methods which safely create Uninit slice from provided slice of maybe
uninitialised or initialised memory.
In addition, add `From<&mut [T]>` implementations (for `T=u8` and
`T=MaybeUninit<u8>`) which do conversion from slice to UninitSlice.
Closes : #552
2023-02-09 17:24:23 +01:00
Paa Kojo Samanpa and GitHub
74b04c7aae
Mark BytesMut::extend_from_slice as inline ( #595 )
...
This function can be hot in applications that do a lot of encoding. Ideally would do the same for `<BytesMut as BufMut>::put_slice` and `<BytesMut as BufMut::put_u8`.
2023-02-04 20:16:41 +01:00
Alice Ryhl and GitHub
21ed332836
chore: prepare bytes v1.4.0 ( #593 )
v1.4.0
2023-01-31 20:38:32 +01:00
brian m. carlson and GitHub
05e9d5cab9
Avoid large reallocations when freezing BytesMut ( #592 )
...
When we freeze a BytesMut, we turn it into a Vec, and then convert that
to a Bytes. Currently, this happen using Vec::into_boxed_slice, which
reallocates to a slice of the same length as the Vev if the length and
the capacity are not equal. This can pose a performance problem if the
Vec is large or if this happens many times in a loop.
Instead, let's compare the length and capacity, and if they're the same,
continue to handle this using into_boxed_slice. Otherwise, since we
have a type of vtable which can handle a separate capacity, the shared
vtable, let's turn our Vec into that kind of Bytes. While this does not
avoid allocation altogether, it performs a fixed size allocation and
avoids any need to memcpy.
2023-01-31 20:04:22 +01:00
0xc0001a2040 and GitHub
f15bba3375
Document which functions require std ( #591 )
2023-01-31 11:42:28 +01:00
c93a94b974
Fix duplicate "the the" typos ( #585 )
...
Co-authored-by: Nicolae Mihalache <[email protected] >
2022-12-20 11:49:55 +01:00
Matthijs van Otterdijk and GitHub
050d65b2ce
make IntoIter constructor public ( #581 )
2022-11-25 22:48:20 +01:00
Sean Lynch and GitHub
9b227220df
chore: prepare bytes v1.3.0 ( #579 )
v1.3.0
2022-11-21 08:06:49 +01:00
Sean Lynch and GitHub
8a8c41f5c2
Implement native-endian get and put functions for Buf and BufMut ( #576 )
...
Fixes #549
2022-11-14 10:33:36 +01:00
Sean Lynch and GitHub
5c7b4317e0
Update nightly snapshot to the current one ( #577 )
2022-11-14 10:56:33 +09:00
Yotam Ofek and GitHub
6e4b1f244b
Rename and expose BytesMut::spare_capacity_mut ( #572 )
2022-10-04 12:23:07 +02:00
Adam Chalmers and GitHub
a36f661354
docs: Bytes::new etc should return Self not Bytes ( #568 )
2022-08-24 13:30:21 +02:00
Alice Ryhl and GitHub
d1b5d4ceb1
Don't have important data in unused capacity when calling reserve ( #563 )
2022-08-12 12:22:43 +02:00
Alice Ryhl and GitHub
b7249149a9
chore: prepare bytes v1.2.1 ( #561 )
v1.2.1
2022-07-30 11:35:26 +02:00
Matt Schulte and GitHub
d6e1999d97
Fix reserve over allocating underlying buffer ( #560 )
...
Fixes calls to `reserve` when the underlying shared buffer was already
big enough to fit the requested capacity. Previously a new even larger
buffer was created anyways. This could eventually lead to an OOM
condition.
2022-07-30 11:16:32 +02:00
Alice Ryhl and GitHub
38fd42acba
chore: prepare bytes v1.2.0 ( #556 )
v1.2.0
2022-07-19 13:39:58 +02:00
7553a67be2
Fix amortized asymptotics of BytesMut ( #555 )
...
Signed-off-by: Jiahao XU <[email protected] >
Co-authored-by: Frank Steffahn <[email protected] >
2022-07-19 13:17:53 +02:00
cd188cbd67
Add conversion from Bytes to Vec<u8> ( #547 )
...
Signed-off-by: Jiahao XU <[email protected] >
Co-authored-by: Alice Ryhl <[email protected] >
2022-07-13 09:04:23 +02:00
Jiahao XU and GitHub
10d1f6ec5c
Fix: From<BytesMut> fo Vec<u8> implementation ( #554 )
...
Signed-off-by: Jiahao XU <[email protected] >
2022-07-13 08:59:54 +02:00
Jiahao XU and GitHub
068ed41bc0
Add conversion from BytesMut to Vec<u8> ( #543 )
2022-07-10 12:44:29 +02:00