Commit Graph

408 Commits

Author SHA1 Message Date
Alice Ryhl c728c48212 ci: fetch cargo hack from github release (#507)
Co-authored-by: Taiki Endo <te316e89@gmail.com>
2021-08-24 12:33:16 +02:00
Stepan Koltsov d766a57017 BufMut::put_bytes(self, val, cnt) (#487)
Equivalent to

```
for _ in 0..cnt {
    self.put_u8(val);
}
```

but may work faster.

Name and signature is chosen to be consistent with `ptr::write_bytes`.

Include three specializations:
* `Vec<u8>`
* `&mut [u8]`
* `BytesMut`

`BytesMut` and `&mut [u8]` specializations use `ptr::write`, `Vec<u8>`
specialization uses `Vec::resize`.
2021-08-09 02:43:53 +09:00
Stepan Koltsov 6d42b4ccf4 Clarify BufPut::put_int behavior (#486)
* writes low bytes, discards high bytes
* panics if `nbytes` is greater than 8
2021-08-09 02:43:09 +09:00
Alice Ryhl 71f64b1d46 Clarify BufMut allocation guarantees (#501) 2021-08-07 08:22:18 +02:00
Taiki Endo 194e754d2b Remove doc URLs (#498) 2021-08-07 02:06:57 +09:00
Gbillou 404d212212 Keep capacity when unsplit on empty other buf (#502) 2021-07-05 16:46:17 +02:00
Taiki Endo f2fb138256 Use ubuntu-latest instead of ubuntu-16.04 (#497) 2021-05-23 23:09:26 +09:00
Taiki Endo b0ff9ae1a4 Update loom to 0.5 (#494) 2021-04-13 23:58:18 +09:00
Noah 230874f5a1 Fully inline BytesMut::new (#493) 2021-04-11 05:49:33 +09:00
Stepan Koltsov 8640174c94 Specialize copy_to_bytes for Chain and Take (#481)
Avoid allocation when `Take` or `Chain` is composed of `Bytes`
objects.

This works now for `Take`.

`Chain` it works if the requested bytes does not cross boundary
between `Chain` members.
2021-04-11 03:56:35 +09:00
Dan Burkert a43f742c80 Add inline tags to UninitSlice methods (#443)
This appears to be the primary cause of significant performance
regressions in the `prost` test suite in the 0.5 to 0.6 transition.  See
danburkert/prost#381.
2021-04-11 03:19:30 +09:00
Stepan Koltsov 0688750f5f Panic on integer overflow in Chain::remaining (#482)
Make it safer.
2021-02-16 12:44:33 -08:00
Zettroke 62ba4a9c19 override put_slice for &mut [u8] (#483) 2021-02-15 16:35:01 -08:00
Alice Ryhl 1bcd09fecc Make bytes_mut -> chunk_mut rename more easily discoverable (#471) 2021-01-23 15:22:43 +09:00
Christopher Bunn 9b463abdd3 docs: fix broken Take link (#466) 2021-01-20 14:39:23 +09:00
Alice Ryhl 7c22cdf430 prepare 1.0.1 release (#460) 2021-01-11 18:07:46 +01:00
Ralf Jung caff82bb54 use Box::into_raw instead of mem-forget-in-disguise (#458) 2020-12-31 15:07:28 +01:00
laizy 4921a32c48 add inline for Vec::put_slice (#459) 2020-12-31 12:34:39 +01:00
Ralf Jung c061be06e7 CI: run test suite in Miri (#456) 2020-12-29 22:54:48 +01:00
Alice Ryhl ab9d9aa32c Fix deprecation warning (#457) 2020-12-29 22:46:39 +01:00
Carl Lerche ab49a91d86 chore: prepare v1.0.0 release (#453) 2020-12-22 15:30:20 -08:00
Taiki Endo 785d972242 deps: update loom to 0.4 (#452) 2020-12-22 10:30:50 +01:00
Arve Knudsen 21b7fec15e Update readme / changelog (#451) 2020-12-20 07:31:22 -08:00
Carl Lerche d40a3d70c1 Rename Buf/BufMut, methods to chunk/chunk_mut (#450)
The `bytes()` / `bytes_mut()` name implies the method returns the full
set of bytes represented by `Buf`/`BufMut`. To rectify this, the methods
are renamed to `chunk()` and `chunk_mut()` to reflect the partial nature
of the returned byte slice.

`bytes_vectored()` is renamed `chunks_vectored()`.

Closes #447
2020-12-18 11:04:31 -08:00
Carl Lerche a1d54b1c27 remove unused Buf implementation. (#449)
The implementation of `Buf` for `Option<[u8; 1]>` was added to support
`IntoBuf`. The `IntoBuf` trait has since been removed.

Closes #444
2020-12-16 21:51:13 -08:00
Carl Lerche e52da8e1cb chore: prepare for v1.0.0 work (#448) 2020-12-12 08:25:14 -08:00
Ibraheem Ahmed 1772ea8874 Upgrade bytes version from 0.5 to 0.6.0 in README (#441) 2020-11-02 00:10:51 +09:00
Carl Lerche b8e1c52738 prepare v0.6.0 release (#440) 2020-10-20 16:08:25 -07:00
Carl Lerche d58e99485c Add Buf::copy_to_bytes(len) (#439)
This method replaces `Buf::to_bytes()`, providing a method that copies a
subset of the remaining buffer into a `Bytes` value. As this is strictly
more flexible, `to_bytes()` is removed.

Fixes: #129, #398
2020-10-20 11:00:35 -07:00
Carl Lerche 143861dec0 use checked addition with range (#438) 2020-10-20 10:26:38 -07:00
Carl Lerche 14b4e28a5f Switch BufMut::bytes_mut to&mut UninitSlice (#433)
The way BufMut uses MaybeUninit can lead to unsoundness. This replaces
MaybeUnit with a type owned by bytes so we can ensure the usage patterns
are sound.

Refs: #328
2020-10-19 15:48:23 -07:00
Matthias Einwag 79842672f4 De-emphasize Arc implementation in Bytes description (#436)
The previous description focussed a lot on the `Arc` based implementation
of `Bytes`. Given the vtable based implemetation, this is however not the
only valid implementation. This changes the description a bit in order
to de-emaphasize the `Arc` part, and to describe that other implementations
are possible.

This should also be necessary if the vtable gets public.
2020-10-19 12:32:20 -07:00
Carl Lerche 003543a312 remove new fns from combinator structs (#434)
This is not idiomatic.
2020-10-18 09:55:19 -07:00
Carl Lerche 16c888fbea Make BufMut an unsafe trait (#432)
Users of `BufMut` are unable to defend against incorrect implementations
of `BufMut`, this makes the trait unsafe to implement.

Fixes #329
2020-10-16 15:45:38 -07:00
Carl Lerche ad16e65c28 remove ext traits (#431) 2020-10-16 15:16:23 -07:00
Carl Lerche 69b7e70509 Remove BufMut::bytes_vectored_mut() (#430)
There are issues with regard to uninitialized memory. We are avoiding
stabilizing this function for now.
2020-10-16 11:56:03 -07:00
Carl Lerche 5133606f40 prepare for 0.6 work (#428) 2020-10-16 11:49:27 -07:00
Sean McArthur 8ec9733fc7 v0.5.6 2020-07-13 17:58:36 -07:00
Sean McArthur 6c9664f09f Move loom to dev-dependencies (#416) 2020-07-13 16:55:47 -07:00
Taiki Endo 04b732a082 Fix CI failure on Windows (#415)
--no-self-update is necessary because the windows environment cannot
self-update rustup.exe.
2020-07-13 12:33:30 +09:00
Taiki Endo 63c9265f3c Change default lint level to warning and deny warnings in CI (#397) 2020-07-09 09:12:39 -07:00
Sean Leather 6ccbcdfbc0 docs: Clarify what BytesMut is (#375) 2020-07-09 09:11:45 -07:00
Bryan Donlan b83ea40780 BytesMut: Reuse buffer when data fully consumed via Buf
Closes #412
2020-07-08 15:28:36 -07:00
Tomasz Miąsko 1e82681d16 Use ThreadSanitizer CI setup that avoids false positives (#406) 2020-07-07 01:28:47 +09:00
Juan Aguilar 2e16777240 Add inline attribute to BytesMut::as_mut (#410) 2020-07-05 17:43:26 -07:00
Juan Aguilar e81e1c3c4e Add inline attribute to BytesMut::set_len (#408) 2020-07-03 16:47:32 -07:00
Tomasz Miąsko 3d28557ac0 Remove unnecessary synchronization when cloning shared representation (#404) 2020-07-02 18:55:16 -07:00
Sean McArthur 7e158a1f92 v0.5.5 2020-06-18 14:30:11 -07:00
Mikhail Zabaluev c5fe74761d Remove outdated info on BytesMut::with_capacity (#394)
Remove a remark from the doc that pertained to the inline
layout and is no longer true.
2020-05-27 22:02:45 -07:00
Taiki Endo 0218965db5 Migrate CI to GitHub Actions (#392) 2020-05-25 01:41:45 +09:00