Skip to content

Commit

Permalink
Merge pull request #544 from KodrAus/chore/cleanups
Browse files Browse the repository at this point in the history
More housekeeping before stabilization
  • Loading branch information
KodrAus authored Nov 1, 2021
2 parents b32f372 + c84f5b8 commit 82bf896
Show file tree
Hide file tree
Showing 20 changed files with 659 additions and 463 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ on:
pull_request:
push:
branches:
- master
- main
schedule:
- cron: '0 0 * * *'

Expand Down
8 changes: 3 additions & 5 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -80,15 +80,13 @@ source repository.
Unless the changes are fairly minor (like documentation changes or tiny
patches), we require PRs to relevant issues.

Please open PRs against branch:
* `master` when making non-breaking changes
* `breaking` when your changes alter the public API in a breaking manner
Please open PRs against the `main` branch.

If the pull request is still a work in progress, prepend`[WIP] ` in your
title. `WIP bot` will make sure that the PR doesn't accidentally get merged.

> Uuid Project has a minimum rust version policy. Currently `uuid` should
compile with atleast `1.22.0`, and is enforced on our CI builds.
compile with at least `1.22.0`, and is enforced on our CI builds.

When you feel that the PR is ready, please ping one of the maintainers so
they can review your changes.
Expand All @@ -105,7 +103,7 @@ improvements to documentation are always welcome.

We follow the documentation style guidelines as given by [RFC 1574].

[RFC 1574]: https://github.com/rust-lang/rfcs/blob/master/text/1574-more-api-documentation-conventions.md#appendix-a-full-conventions-text
[RFC 1574]: https://github.com/rust-lang/rfcs/blob/main/text/1574-more-api-documentation-conventions.md#appendix-a-full-conventions-text

# Issue Triage
[Issue Triage]: #issue-triage
Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ uuid
[![Latest Version](https://img.shields.io/crates/v/uuid.svg)](https://crates.io/crates/uuid)
[![Join the chat at https://gitter.im/uuid-rs/Lobby](https://badges.gitter.im/Join%20Chat.svg)](https://gitter.im/uuid-rs/Lobby?utm_source=badge&utm_medium=badge&utm_content=badge)
![Minimum rustc version](https://img.shields.io/badge/rustc-1.46.0+-yellow.svg)
[![Build Status](https://ci.appveyor.com/api/projects/status/github/uuid-rs/uuid?branch=master&svg=true)](https://ci.appveyor.com/project/uuid-rs/uuid/branch/master)
[![Build Status](https://travis-ci.org/uuid-rs/uuid.svg?branch=master)](https://travis-ci.org/uuid-rs/uuid)
[![Build Status](https://ci.appveyor.com/api/projects/status/github/uuid-rs/uuid?branch=main&svg=true)](https://ci.appveyor.com/project/uuid-rs/uuid/branch/main)
[![Build Status](https://travis-ci.org/uuid-rs/uuid.svg?branch=main)](https://travis-ci.org/uuid-rs/uuid)
[![Average time to resolve an issue](https://isitmaintained.com/badge/resolution/uuid-rs/uuid.svg)](https://isitmaintained.com/project/uuid-rs/uuid "Average time to resolve an issue")
[![Percentage of issues still open](https://isitmaintained.com/badge/open/uuid-rs/uuid.svg)](https://isitmaintained.com/project/uuid-rs/uuid "Percentage of issues still open")
[![FOSSA Status](https://app.fossa.com/api/projects/git%2Bgithub.com%2Fuuid-rs%2Fuuid.svg?type=shield)](https://app.fossa.com/projects/git%2Bgithub.com%2Fuuid-rs%2Fuuid?ref=badge_shield)
Expand Down
24 changes: 12 additions & 12 deletions benches/format_str.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,61 +6,61 @@ use test::Bencher;
use uuid::Uuid;

#[bench]
fn bench_hyphen(b: &mut Bencher) {
fn hyphenated(b: &mut Bencher) {
let uuid = Uuid::parse_str("F9168C5E-CEB2-4faa-B6BF-329BF39FA1E4").unwrap();
b.iter(|| {
let mut buffer = [0_u8; 36];
write!(&mut buffer as &mut [_], "{:x}", uuid.to_hyphenated()).unwrap();
test::black_box(buffer);
buffer
});
}

#[bench]
fn bench_simple(b: &mut Bencher) {
fn simple(b: &mut Bencher) {
let uuid = Uuid::parse_str("F9168C5E-CEB2-4faa-B6BF-329BF39FA1E4").unwrap();
b.iter(|| {
let mut buffer = [0_u8; 32];
write!(&mut buffer as &mut [_], "{:x}", uuid.to_simple()).unwrap();
test::black_box(buffer);
buffer
})
}

#[bench]
fn bench_urn(b: &mut Bencher) {
fn urn(b: &mut Bencher) {
let uuid = Uuid::parse_str("F9168C5E-CEB2-4faa-B6BF-329BF39FA1E4").unwrap();
b.iter(|| {
let mut buffer = [0_u8; 36 + 9];
write!(&mut buffer as &mut [_], "{:x}", uuid.to_urn()).unwrap();
test::black_box(buffer);
buffer
})
}

#[bench]
fn bench_encode_hyphen(b: &mut Bencher) {
fn encode_hyphen(b: &mut Bencher) {
let uuid = Uuid::parse_str("F9168C5E-CEB2-4faa-B6BF-329BF39FA1E4").unwrap();
b.iter(|| {
let mut buffer = [0_u8; 36];
uuid.to_hyphenated().encode_lower(&mut buffer);
test::black_box(buffer);
buffer
});
}

#[bench]
fn bench_encode_simple(b: &mut Bencher) {
fn encode_simple(b: &mut Bencher) {
let uuid = Uuid::parse_str("F9168C5E-CEB2-4faa-B6BF-329BF39FA1E4").unwrap();
b.iter(|| {
let mut buffer = [0_u8; 32];
uuid.to_simple().encode_lower(&mut buffer);
test::black_box(buffer);
buffer
})
}

#[bench]
fn bench_encode_urn(b: &mut Bencher) {
fn encode_urn(b: &mut Bencher) {
let uuid = Uuid::parse_str("F9168C5E-CEB2-4faa-B6BF-329BF39FA1E4").unwrap();
b.iter(|| {
let mut buffer = [0_u8; 36 + 9];
uuid.to_urn().encode_lower(&mut buffer);
test::black_box(buffer);
buffer
})
}
58 changes: 0 additions & 58 deletions benches/invalid_parse_str.rs

This file was deleted.

4 changes: 0 additions & 4 deletions benches/mod.rs

This file was deleted.

50 changes: 50 additions & 0 deletions benches/parse_str.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
#![feature(test)]
extern crate test;

use test::Bencher;
use uuid::Uuid;

#[bench]
fn parse_nil(b: &mut Bencher) {
b.iter(|| Uuid::parse_str("00000000000000000000000000000000"));
}

#[bench]
fn parse_nil_hyphenated(b: &mut Bencher) {
b.iter(|| Uuid::parse_str("00000000-0000-0000-0000-000000000000"));
}

#[bench]
fn parse_random(b: &mut Bencher) {
b.iter(|| Uuid::parse_str("67e5504410b1426f9247bb680e5fe0c8"));
}

#[bench]
fn parse_random_hyphenated(b: &mut Bencher) {
b.iter(|| Uuid::parse_str("67e55044-10b1-426f-9247-bb680e5fe0c8"));
}

#[bench]
fn parse_urn(b: &mut Bencher) {
b.iter(|| Uuid::parse_str("urn:uuid:67e55044-10b1-426f-9247-bb680e5fe0c8"));
}

#[bench]
fn parse_invalid_len(b: &mut Bencher) {
b.iter(|| Uuid::parse_str("F9168C5E-CEB2-4faa-BBF-329BF39FA1E4"))
}

#[bench]
fn parse_invalid_character(b: &mut Bencher) {
b.iter(|| Uuid::parse_str("F9168C5E-CEB2-4faa-BGBF-329BF39FA1E4"))
}

#[bench]
fn parse_invalid_group_len(b: &mut Bencher) {
b.iter(|| Uuid::parse_str("01020304-1112-2122-3132-41424344"));
}

#[bench]
fn parse_invalid_groups(b: &mut Bencher) {
b.iter(|| Uuid::parse_str("F9168C5E-CEB2-4faa-B6BFF329BF39FA1E4"));
}
48 changes: 0 additions & 48 deletions benches/serde_support.rs

This file was deleted.

1 change: 0 additions & 1 deletion benches/slog_support/mod.rs

This file was deleted.

15 changes: 0 additions & 15 deletions benches/slog_support/parse_str.rs

This file was deleted.

39 changes: 0 additions & 39 deletions benches/valid_parse_str.rs

This file was deleted.

19 changes: 4 additions & 15 deletions shared/parser.rs
Original file line number Diff line number Diff line change
Expand Up @@ -34,15 +34,9 @@ pub fn parse_str(mut input: &str) -> Result<[u8; 16], Error> {

if len == 45 && input.starts_with("urn:uuid:") {
input = &input[9..];
} else if !len_matches_any(
len,
&[36, 32],
) {
} else if !len_matches_any(len, &[36, 32]) {
return Err(ErrorKind::InvalidLength {
expected: ExpectedLength::Any(&[
36,
32,
]),
expected: ExpectedLength::Any(&[36, 32]),
found: len,
}
.into());
Expand All @@ -58,10 +52,7 @@ pub fn parse_str(mut input: &str) -> Result<[u8; 16], Error> {
if digit as usize >= 32 && group != 4 {
if group == 0 {
return Err(ErrorKind::InvalidLength {
expected: ExpectedLength::Any(&[
36,
32,
]),
expected: ExpectedLength::Any(&[36, 32]),
found: len,
}
.into());
Expand Down Expand Up @@ -93,9 +84,7 @@ pub fn parse_str(mut input: &str) -> Result<[u8; 16], Error> {
};

return Err(ErrorKind::InvalidGroupLength {
expected: ExpectedLength::Exact(
GROUP_LENS[group],
),
expected: ExpectedLength::Exact(GROUP_LENS[group]),
found: found as usize,
group,
}
Expand Down
Loading

0 comments on commit 82bf896

Please sign in to comment.