Commit Graph
178 Commits
Author SHA1 Message Date
Stepan KoltsovandCarl Lerche 613d4bd5d5 Reimplement fmt::Debug for Bytes and BytesMut (#84)
Standard `Debug` implementation for `[u8]` is comma separated list
of numbers. Since large amount of byte strings are in fact ASCII
strings or contain a lot of ASCII strings (e. g. HTTP), it is
convenient to print strings as ASCII when possible.
2017-03-20 21:09:44 -07:00
Carl LercheandGitHub dc9c8e304e Misc CI fixes (#89)
Limit the number of threads when using qemu to 1. Also, don't bother
running the stress test as this will trigger qemu bugs. Finally, also
make the stress test actually stress test.
2017-03-20 10:12:23 -07:00
Carl Lerche bed128b2c0 Clarify when BufMut::bytes_mut can return &[]
Closes #79
2017-03-19 13:58:44 -07:00
Dan BurkertandCarl Lerche 5a265cc8eb Add inline attributes to Vec's MutBuf methods (#80)
I found this significantly improved a
[benchmark](https://gist.github.com/danburkert/34a7d6680d97bc86dca7f396eb8d0abf)
which calls `bytes_mut`, writes 1 byte, and advances the pointer with
`advance_mut` in a pretty tight loop. In particular, it seems to be the
inline annotation on `bytes_mut` which had the most effect. I also took
the opportunity to simplify the bounds checking in advance_mut.

before:

```
test encode_varint_small  ... bench:         540 ns/iter (+/- 85) = 1481 MB/s
```

after:

```
test encode_varint_small  ... bench:         422 ns/iter (+/- 24) = 1895 MB/s
```

As you can see, the variance is also significantly improved.

Interestingly, I tried to change the last statement in `bytes_mut` from

```
&mut slice::from_raw_parts_mut(ptr, cap)[len..]
```

to

```
slice::from_raw_parts_mut(ptr.offset(len as isize), cap - len)
```

but, this caused a very measurable perf regression (almost completely
negating the gains from marking bytes_mut inline).
2017-03-19 13:54:09 -07:00
Dan BurkertandCarl Lerche 4fe4e9429a Clarify BufMut::advance_mut docs (#78)
Also fixes an issue with a line wrap in the middle of an inline code
block.
2017-03-19 13:53:33 -07:00
Carl Lerche 9a4018e757 Fix tests on nightly
Closes #83
2017-03-19 09:08:41 -07:00
Carl LercheandGitHub 99fba239db Tweak docs (#76) 2017-03-16 12:11:10 -07:00
Carl Lerche dcd6c184e4 Bump version to v0.4.1 v0.4.1 2017-03-15 09:36:52 -07:00
Carl Lerche 9e6d65a1d6 Add a changelog 2017-03-15 09:36:11 -07:00
Carl Lerche 02b6144644 Depend on released iovec crate 2017-03-15 09:23:10 -07:00
Carl Lerche 2e319b51be Impl Extend for BytesMut 2017-03-07 15:06:47 -08:00
Carl Lerche 06b94c55b0 Remove buf::Source in favor of buf::IntoBuf
The `Source` trait was essentially covering the same case as `IntoBuf`,
so remove it.

While technically a breaking change, this should not have any impact due
to:

1) There are no reverse dependencies that currently depend on `bytes`
2) Source was not supposed to be implemented externally
3) IntoBuf provides the same implementations as `Source`

Given these points, the change should be safe to apply.
2017-03-07 11:30:08 -08:00
Carl Lerche d70f575afd Provide Debug impls for all types 2017-03-07 10:20:58 -08:00
Carl Lerche 933b8b26f6 BytesMut::reserve should avoid small allocations
This change tracks the original capacity requested when `BytesMut` is
first created. This capacity is used when a `reserve` needs to allocate
due to the current view being too small. The newly allocated buffer will
be sized the same as the original allocation.
2017-03-02 16:14:14 -08:00
Carl Lerche b44fc31463 Move Inner constructions to struct fns 2017-03-02 13:46:14 -08:00
Carl Lerche d0142aa6da Clarify API edge cases 2017-03-01 18:30:58 -08:00
Carl Lerche 94396162b2 Implement chain combinator for Buf 2017-03-01 14:22:53 -08:00
Carl Lerche bb9bf7ee3e Add vectored support to Buf and BufMut 2017-03-01 13:18:29 -08:00
Carl Lerche 4462056e26 Move stray impls into appropriate file 2017-03-01 13:15:11 -08:00
Carl Lerche 30c0e4e9c8 Merge remote-tracking branch 'alexcrichton/more-object-safe' 2017-03-01 10:44:22 -08:00
Alex Crichton d19c929018 Expand object-safe impls slightly
Add `?Sized` bounds to work for DST objects and also add impls for `Box` as well
as `&mut`
2017-03-01 10:37:30 -08:00
Carl Lerche 8fec8a92ad Implement iterator adapter for Buf 2017-03-01 10:03:28 -08:00
Carl Lerche 4f8c565111 Implement FromBuf and Buf::collect
Enables collecting the contents of a `Buf` value into a relevant
concrete buffer implementation.
2017-03-01 09:30:13 -08:00
Carl Lerche fd8f716e68 Rename a test file to match lib naming 2017-02-28 19:10:30 -08:00
Carl Lerche 22a5fb8d9b Rename some functions on Bytes 2017-02-28 19:05:25 -08:00
Carl Lerche e842296c4d Implement IntoBuf for T: Buf 2017-02-28 19:02:45 -08:00
Carl Lerche f7f8d6c9ef Don't re-export everything from buf module 2017-02-28 17:09:43 -08:00
Alex CrichtonandCarl Lerche 87160b6232 Add doc(html_root_url)
Allows links in other crates to link to crates.io docs of bytes itself.
2017-02-28 16:55:10 -08:00
Carl Lerche 4466b75ae4 Split buf.rs into separate files 2017-02-28 15:21:20 -08:00
Carl Lerche 9eb5bd50b8 Bump version to 0.4 v0.4.0 2017-02-24 10:35:53 -08:00
Carl Lerche b46d3fd32e Tweak growth algorithm in BytesMut::reserve 2017-02-20 21:07:25 -08:00
Carl Lerche 8c11456185 Combine reserve and try_reclaim
Instead of providing a separate `try_reclaim` function, `reserve` will
attempt to reclaim the existing buffer before allocating.
2017-02-20 19:31:02 -08:00
Carl Lerche 128c56ddc4 Fix link to documentation 2017-02-20 14:33:35 -08:00
Carl Lerche 5c6eadfcb0 More docs and polish 2017-02-20 14:31:26 -08:00
Carl Lerche c6fe5a1e4f Add some missing Bytes impls and fns 2017-02-20 14:03:37 -08:00
Carl Lerche 99aafb0a22 Fix uploading master docs 2017-02-20 12:43:15 -08:00
Carl Lerche cf5a1bc4f1 Rewrite Bytes / BytesMut core implementation
The previous implementation didn't factor in a single `Bytes` handle
being stored in an `Arc`. This new implementation correctly impelments
both `Bytes` and `BytesMut` such that both are `Sync`.

The rewrite also increases the number of bytes that can be stored
inline.
2017-02-20 10:41:20 -08:00
Carl Lerche 0360f191f8 Finish up docs 2017-02-17 12:23:09 -08:00
Carl Lerche aa06b6dd6a More docs 2017-02-17 11:37:19 -08:00
Carl Lerche 5048eec143 Docs & polish for Buf 2017-02-16 22:15:17 -08:00
Carl Lerche 268226051d Implement Hash and Borrow for Bytes / BytesMut 2017-02-16 16:52:56 -08:00
Carl Lerche 646624c130 Polish API surface 2017-02-16 16:44:38 -08:00
Carl Lerche bababa8797 Remove Take/TakeMut 2017-02-16 10:36:00 -08:00
Carl Lerche 0e0066e8a0 Write docs and remove unecessary fns and types 2017-02-16 10:26:48 -08:00
Carl Lerche 53d1c788e0 Start writing docs for bytes 2017-02-15 14:43:11 -08:00
Carl Lerche 4c6ebeba87 Provide two versions of drain_to and split_off
* `drain_to` and `split_off` take &self and return Bytes.
* `drain_to_mut` and `split_off_mut` take &mut self and return BytesMut
2017-02-15 12:46:27 -08:00
Carl Lerche 8da9e81469 Tweak CI settings 2017-02-15 09:45:30 -08:00
Carl Lerche 36c9a8c287 Support static refs and inline short byte slices 2017-02-15 09:38:55 -08:00
Carl Lerche 44d40d34d7 Cleanup Bytes 2017-02-10 12:04:32 -08:00
Aaron J. ToddandCarl Lerche 70fed562eb Update byteorder to 1.0 2017-02-06 11:58:44 -08:00