chore(rust): Release 0.13.3

This commit is contained in:
Dmitry Dygalo 2021-12-09 23:46:40 +01:00 committed by Dmitry Dygalo
parent 2d061579c8
commit 90b0cb089b
3 changed files with 23 additions and 6 deletions

View File

@ -2,6 +2,10 @@
## [Unreleased]
### Performance
- Optimize the loop implementation used for uniqueness check on short arrays.
## [0.13.3] - 2021-12-08
### Changed

View File

@ -199,7 +199,7 @@
"invalid": [
{
"foo": 1,
"bar": 2
"bar": 2
}
]
},
@ -917,7 +917,12 @@
],
{
"12": 12
}
},
13,
"14",
[
15
]
]
],
"invalid": [
@ -927,6 +932,10 @@
3,
4,
5,
6,
7,
8,
9,
1
],
[

View File

@ -57,7 +57,7 @@ impl Hash for HashedValue<'_> {
// Calculated for an array of mixed types, large homogenous arrays of primitive values might be
// processed faster with different thresholds, but this one gives a good baseline for the common
// case.
const ITEMS_SIZE_THRESHOLD: usize = 11;
const ITEMS_SIZE_THRESHOLD: usize = 15;
#[inline]
pub(crate) fn is_unique(items: &[Value]) -> bool {
@ -72,12 +72,16 @@ pub(crate) fn is_unique(items: &[Value]) -> bool {
} else if size <= ITEMS_SIZE_THRESHOLD {
// If the array size is small enough we can compare all elements pairwise, which will
// be faster than calculating hashes for each element, even if the algorithm is O(N^2)
for (idx, item) in items.iter().enumerate() {
for other_item in items.iter().skip(idx + 1) {
if equal(item, other_item) {
let mut idx = 0_usize;
while idx < items.len() {
let mut inner_idx = idx + 1;
while inner_idx < items.len() {
if equal(&items[idx], &items[inner_idx]) {
return false;
}
inner_idx += 1;
}
idx += 1;
}
true
} else {