Skip to content

Commit

Permalink
Merge pull request #172 from bluss/min-const-gen
Browse files Browse the repository at this point in the history
Use const generics in ArrayVec
  • Loading branch information
bluss authored Mar 23, 2021
2 parents b5efc03 + 1820970 commit a58e1a5
Show file tree
Hide file tree
Showing 12 changed files with 460 additions and 616 deletions.
7 changes: 3 additions & 4 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,15 +13,14 @@ env:
jobs:
tests:
runs-on: ubuntu-latest
continue-on-error: true
strategy:
matrix:
include:
- rust: 1.36.0 # MSRV
- rust: 1.51.0 # MSRV
features: serde
- rust: stable
features: serde
- rust: stable
features: array-sizes-33-128 array-sizes-129-255
features:
- rust: beta
features: serde
- rust: nightly
Expand Down
3 changes: 0 additions & 3 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -39,9 +39,6 @@ default = ["std"]
std = []
unstable-const-fn = []

array-sizes-33-128 = []
array-sizes-129-255 = []

[profile.bench]
debug = true
[profile.release]
Expand Down
12 changes: 6 additions & 6 deletions benches/arraystring.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ use arrayvec::ArrayString;
use bencher::Bencher;

fn try_push_c(b: &mut Bencher) {
let mut v = ArrayString::<[u8; 512]>::new();
let mut v = ArrayString::<512>::new();
b.iter(|| {
v.clear();
while v.try_push('c').is_ok() {
Expand All @@ -18,7 +18,7 @@ fn try_push_c(b: &mut Bencher) {
}

fn try_push_alpha(b: &mut Bencher) {
let mut v = ArrayString::<[u8; 512]>::new();
let mut v = ArrayString::<512>::new();
b.iter(|| {
v.clear();
while v.try_push('α').is_ok() {
Expand All @@ -30,7 +30,7 @@ fn try_push_alpha(b: &mut Bencher) {

// Yes, pushing a string char-by-char is slow. Use .push_str.
fn try_push_string(b: &mut Bencher) {
let mut v = ArrayString::<[u8; 512]>::new();
let mut v = ArrayString::<512>::new();
let input = "abcαβγ“”";
b.iter(|| {
v.clear();
Expand All @@ -45,7 +45,7 @@ fn try_push_string(b: &mut Bencher) {
}

fn push_c(b: &mut Bencher) {
let mut v = ArrayString::<[u8; 512]>::new();
let mut v = ArrayString::<512>::new();
b.iter(|| {
v.clear();
while !v.is_full() {
Expand All @@ -57,7 +57,7 @@ fn push_c(b: &mut Bencher) {
}

fn push_alpha(b: &mut Bencher) {
let mut v = ArrayString::<[u8; 512]>::new();
let mut v = ArrayString::<512>::new();
b.iter(|| {
v.clear();
while !v.is_full() {
Expand All @@ -69,7 +69,7 @@ fn push_alpha(b: &mut Bencher) {
}

fn push_string(b: &mut Bencher) {
let mut v = ArrayString::<[u8; 512]>::new();
let mut v = ArrayString::<512>::new();
let input = "abcαβγ“”";
b.iter(|| {
v.clear();
Expand Down
10 changes: 5 additions & 5 deletions benches/extend.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ use bencher::Bencher;
use bencher::black_box;

fn extend_with_constant(b: &mut Bencher) {
let mut v = ArrayVec::<[u8; 512]>::new();
let mut v = ArrayVec::<u8, 512>::new();
let cap = v.capacity();
b.iter(|| {
v.clear();
Expand All @@ -22,7 +22,7 @@ fn extend_with_constant(b: &mut Bencher) {
}

fn extend_with_range(b: &mut Bencher) {
let mut v = ArrayVec::<[u8; 512]>::new();
let mut v = ArrayVec::<u8, 512>::new();
let cap = v.capacity();
b.iter(|| {
v.clear();
Expand All @@ -34,7 +34,7 @@ fn extend_with_range(b: &mut Bencher) {
}

fn extend_with_slice(b: &mut Bencher) {
let mut v = ArrayVec::<[u8; 512]>::new();
let mut v = ArrayVec::<u8, 512>::new();
let data = [1; 512];
b.iter(|| {
v.clear();
Expand All @@ -46,7 +46,7 @@ fn extend_with_slice(b: &mut Bencher) {
}

fn extend_with_write(b: &mut Bencher) {
let mut v = ArrayVec::<[u8; 512]>::new();
let mut v = ArrayVec::<u8, 512>::new();
let data = [1; 512];
b.iter(|| {
v.clear();
Expand All @@ -57,7 +57,7 @@ fn extend_with_write(b: &mut Bencher) {
}

fn extend_from_slice(b: &mut Bencher) {
let mut v = ArrayVec::<[u8; 512]>::new();
let mut v = ArrayVec::<u8, 512>::new();
let data = [1; 512];
b.iter(|| {
v.clear();
Expand Down
151 changes: 0 additions & 151 deletions src/array.rs

This file was deleted.

Loading

0 comments on commit a58e1a5

Please sign in to comment.