Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
88 commits
Select commit Hold shift + click to select a range
ba037c9
[ValueRef] Proof on concept.
3Hren Jul 13, 2015
a8e480f
[ValueRef] Planning.
3Hren Jul 13, 2015
427ada8
ValueRef: marker error conversion.
3Hren Jul 14, 2015
3aff372
ValueRef: buffer fill error conversion.
3Hren Jul 15, 2015
9baeafa
Doc: minor update.
3Hren Jul 15, 2015
ff75c0e
ValueRef: handle EOF while reading length.
3Hren Jul 15, 2015
17a770a
Planning: minor notice.
3Hren Jul 15, 2015
65282fd
ValueRef: handling UTF-8 errors.
3Hren Jul 15, 2015
f6c797c
Doc: more comments.
3Hren Jul 15, 2015
32b0c6f
ValueRef: decoding fixed strings.
3Hren Jul 16, 2015
5349d36
Marker: rename planning.
3Hren Jul 16, 2015
60ac905
Wording.
3Hren Jul 16, 2015
bcc34fd
Refactoring: code decomposition.
3Hren Jul 16, 2015
b852ce9
Cleanup: minor.
3Hren Jul 17, 2015
cb7b6c6
Doc: wording.
3Hren Jul 17, 2015
cbbe83b
ValueRef: decoding strings with 2-byte length.
3Hren Jul 17, 2015
ad90960
ValueRef: decoding all types of strings.
3Hren Jul 17, 2015
1bae03c
ValueRef: functional decomposition.
3Hren Jul 17, 2015
5a2fee0
ValueRef: naive bin8 decoding.
3Hren Jul 17, 2015
dc3e6f9
ValueRef: decomposition.
3Hren Jul 17, 2015
b2a29de
Misc: code reuse.
3Hren Jul 17, 2015
270ae56
ValueRef: done with binary decoding.
3Hren Jul 17, 2015
83adebd
ValueRef: ext1 decoding.
3Hren Jul 17, 2015
07b2357
ValueRef: decoding all fixed ext types.
3Hren Jul 17, 2015
54ed999
ValueRef: decoding all types of exts now.
3Hren Jul 17, 2015
867c6bf
ValueRef: map decoding, first blood.
3Hren Jul 18, 2015
c413ca3
ValueRef: map - code clean.
3Hren Jul 18, 2015
3aab5ba
Misc: minor code style.
3Hren Jul 18, 2015
552d190
Bench: value ref benchmark added.
3Hren Jul 18, 2015
aeb5957
ValueRef: planning.
3Hren Jul 19, 2015
1a6a047
ValueRef: code reuse.
3Hren Jul 19, 2015
b8ba23d
ValueRef: decoding all types of maps.
3Hren Jul 19, 2015
85cd673
ValueRef: array decoding, first blood.
3Hren Jul 19, 2015
b4aa850
ValueRef: decoding all types of arrays.
3Hren Jul 19, 2015
6556995
ValueRef: decoding positive fixnum.
3Hren Jul 20, 2015
0ac82aa
Misc: planning.
3Hren Jul 20, 2015
e6371c4
ValueRef: decoding fixed negative integers.
3Hren Jul 20, 2015
8a8d98a
ValueRef: decoding all unsigned integers.
3Hren Jul 20, 2015
557f7dd
ValueRef: decoding all signed integer types.
3Hren Jul 20, 2015
d155e10
UT: uncomment one test case.
3Hren Jul 20, 2015
1d71629
ValueRef: replace marker placeholder.
3Hren Jul 20, 2015
9ec90a8
ValueRef: all floats now can be decoded.
3Hren Jul 20, 2015
769379e
ValueRef: all types can now be decoded.
3Hren Jul 20, 2015
603fb9e
Misc: dead comments elimination.
3Hren Jul 20, 2015
0d2f511
ValueRef: weak type restrictions for decoding.
3Hren Jul 21, 2015
7943eb0
ValueRef: more docs.
3Hren Jul 21, 2015
2a29afc
ValueRef: handling the reserved type.
3Hren Jul 21, 2015
6a0f540
ValueRef: code decomposition.
3Hren Jul 21, 2015
4aef10f
ValueRef: minor renaming.
3Hren Jul 21, 2015
54994ef
Misc: renaming again.
3Hren Jul 21, 2015
e87e6e9
Misc: proper variable names.
3Hren Jul 21, 2015
4b80c2b
Bench: added complex value ref reader benchmark.
3Hren Jul 21, 2015
977c243
ValueRef: encoder - the beginning.
3Hren Jul 25, 2015
bc7a621
UT: example with Vec write.
3Hren Jul 25, 2015
9b2d8a9
Misc: func tests decomposition.
3Hren Jul 26, 2015
defa516
ValueRef: writing nil value.
3Hren Jul 26, 2015
d0c1bc0
UT: enable some value & value_ref tests.
3Hren Jul 26, 2015
4c37608
UT: tested writing into a too small buffer.
3Hren Jul 26, 2015
6ed1384
ValueRef: encoding bool values.
3Hren Jul 28, 2015
56cf544
ValueRef: writing signed integers.
3Hren Jul 28, 2015
7a9af11
ValueRef: writing unsinged integers.
3Hren Jul 28, 2015
ffafe80
Misc: planning.
3Hren Jul 28, 2015
35df38b
ValueRef: writing floats.
3Hren Jul 28, 2015
31f60be
ValueRef: writing strings.
3Hren Jul 28, 2015
4e095af
ValueRef: writing binaries.
3Hren Jul 28, 2015
7320857
ValueRef: writing arrays.
3Hren Jul 28, 2015
c82483c
ValueRef: writing maps.
3Hren Jul 28, 2015
3c08e68
ValueRef: writing exts.
3Hren Jul 28, 2015
880bfbe
ValueRef: fixed includes for PR.
3Hren Jul 28, 2015
0a2fefa
ValueRef: display trait for encode error.
3Hren Jul 30, 2015
f636dc8
ValueRef: error trait for encode error.
3Hren Jul 31, 2015
108add5
UT: more checks.
3Hren Jul 31, 2015
1de534a
UT: minor renaming.
3Hren Jul 31, 2015
72db127
ValueRef: display and error traits for decoding.
3Hren Jul 31, 2015
8ab09fd
Misc: planning.
3Hren Jul 31, 2015
b56c3ea
Value: integers and float enums are now Copy.
3Hren Aug 1, 2015
4b975e3
ValueRef: to owned value conversion.
3Hren Aug 1, 2015
e1330a3
Bench: converting to owned.
3Hren Aug 1, 2015
944a4a7
Changelog: update, brief doc added.
3Hren Aug 1, 2015
ae60f1e
Doc: `to_owned` method has been documented.
3Hren Aug 1, 2015
b3e30e6
Misc: style.
3Hren Aug 1, 2015
b3c4d8d
ValueRef: documentation added.
3Hren Aug 1, 2015
f78528f
Misc: planning.
3Hren Aug 1, 2015
51a6ea2
Misc: wording.
3Hren Aug 1, 2015
01fa09c
ValueRef: more documentation for decoding.
3Hren Aug 1, 2015
86cf871
Misc: one task less.
3Hren Aug 1, 2015
b395cba
Changelog: merge.
3Hren Aug 1, 2015
93b5100
Misc: trait renaming.
3Hren Aug 1, 2015
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,12 @@ This project adheres to [Semantic Versioning](http://semver.org/).
- FixedValue* -> FixVal*

## [Unreleased][unreleased]
- Nothing yet.

## 0.4.0 - 2015-07-17
### Added
- Low level `write_str` function allows to serialize the UTF-8 encoded strings the most efficient way.
- Low level `write_bin` function allows to serialize the binary array the most efficient way.
- Implemented `std::error::Error` trait for error types.

## 0.3.2 - 2015-07-05
Expand Down
58 changes: 58 additions & 0 deletions benches/bench.rs
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,21 @@ fn from_string_read_value(b: &mut Bencher) {
});
}

#[bench]
fn from_string_read_value_ref(b: &mut Bencher) {
// Lorem ipsum dolor sit amet.
let buf = [
0xbb, 0x4c, 0x6f, 0x72, 0x65, 0x6d, 0x20, 0x69, 0x70, 0x73, 0x75,
0x6d, 0x20, 0x64, 0x6f, 0x6c, 0x6f, 0x72, 0x20, 0x73, 0x69, 0x74,
0x20, 0x61, 0x6d, 0x65, 0x74, 0x2e
];

b.iter(|| {
let res = read_value_ref(&mut &buf[..]).unwrap();
test::black_box(res);
});
}

#[bench]
fn from_complex_read_value(b: &mut Bencher) {
let buf = [
Expand All @@ -61,6 +76,49 @@ fn from_complex_read_value(b: &mut Bencher) {
});
}

#[bench]
fn from_complex_read_value_ref(b: &mut Bencher) {
let buf = [
0x95, // Fixed array with 5 len.
0xc0, // Nil.
0x2a, // 42.
0xcb, 0x40, 0x9, 0x21, 0xca, 0xc0, 0x83, 0x12, 0x6f, // 3.1415
// Fixed string with "Lorem ipsum dolor sit amet." content.
0xbb, 0x4c, 0x6f, 0x72, 0x65, 0x6d, 0x20, 0x69, 0x70, 0x73, 0x75,
0x6d, 0x20, 0x64, 0x6f, 0x6c, 0x6f, 0x72, 0x20, 0x73, 0x69, 0x74,
0x20, 0x61, 0x6d, 0x65, 0x74, 0x2e,
0x81, // Fixed map with 1 len.
0xa3, 0x6b, 0x65, 0x79, // Key "key".
0xa5, 0x76, 0x61, 0x6c, 0x75, 0x65 // Value: "value".
];

b.iter(|| {
let res = read_value_ref(&mut &buf[..]).unwrap();
test::black_box(res);
});
}

#[bench]
fn from_complex_read_value_ref_to_owned(b: &mut Bencher) {
let buf = [
0x95, // Fixed array with 5 len.
0xc0, // Nil.
0x2a, // 42.
0xcb, 0x40, 0x9, 0x21, 0xca, 0xc0, 0x83, 0x12, 0x6f, // 3.1415
// Fixed string with "Lorem ipsum dolor sit amet." content.
0xbb, 0x4c, 0x6f, 0x72, 0x65, 0x6d, 0x20, 0x69, 0x70, 0x73, 0x75,
0x6d, 0x20, 0x64, 0x6f, 0x6c, 0x6f, 0x72, 0x20, 0x73, 0x69, 0x74,
0x20, 0x61, 0x6d, 0x65, 0x74, 0x2e,
0x81, // Fixed map with 1 len.
0xa3, 0x6b, 0x65, 0x79, // Key "key".
0xa5, 0x76, 0x61, 0x6c, 0x75, 0x65 // Value: "value".
];

b.iter(|| {
let res = read_value_ref(&mut &buf[..]).unwrap().to_owned();
test::black_box(res);
});
}

#[bench]
fn from_i64_read_i64_loosely(b: &mut Bencher) {
Expand Down
6 changes: 6 additions & 0 deletions src/decode.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,10 @@ use byteorder::ReadBytesExt;

use super::Marker;

#[path = "decode/value_ref.rs"]
pub mod value_ref;
pub use self::value_ref::read_value_ref;

/// Represents an error that can occur when attempting to read bytes from the reader.
///
/// This is a thin wrapper over the standard `io::Error` type. Namely, it adds one additional error
Expand All @@ -40,6 +44,7 @@ impl Error for ReadError {
fn description(&self) -> &str {
match *self {
ReadError::UnexpectedEOF => "unexpected end of file while reading MessagePack value",
// TODO: Probably we should give here a short description that I/O error occurs.
ReadError::Io(ref err) => err.description(),
}
}
Expand Down Expand Up @@ -1038,6 +1043,7 @@ fn read_str_data<'r, R>(rd: &mut R, len: u32, buf: &'r mut[u8]) -> Result<&'r st
///
// TODO: it is better to return &str; may panic on len mismatch; extend documentation.
// TODO: Also it's possible to implement all borrowing functions for all `BufRead` implementors.
// TODO: It's not necessary to use cursor, use slices instead.
pub fn read_str_ref(rd: &[u8]) -> Result<&[u8], DecodeStringError> {
let mut cur = io::Cursor::new(rd);
let len = try!(read_str_len(&mut cur));
Expand Down
Loading