Skip to content

Commit 464837b

Browse files
committed
feat!: Use hashbrown
1 parent 76c3f9f commit 464837b

File tree

6 files changed

+12
-11
lines changed

6 files changed

+12
-11
lines changed

Cargo.toml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,11 @@ keywords = ["wot", "WebofThings"]
99

1010
[features]
1111
default = ["std"]
12-
std = ["serde/std", "serde_json/std", "serde_with/std", "time/std", "oxilangtag/std"]
13-
alloc = ["serde/alloc", "serde_json/alloc", "serde_with/alloc", "time/alloc", "oxilangtag/alloc"]
12+
std = ["serde/std", "serde_json/std", "serde_with/std", "time/std", "oxilangtag/std", "hashbrown/allocator-api2"]
13+
alloc = ["serde/alloc", "serde_json/alloc", "serde_with/alloc", "time/alloc", "oxilangtag/alloc", "hashbrown/allocator-api2"]
1414

1515
[dependencies]
16+
hashbrown = { version = "0.15.1", default-features = false, features = ["core", "serde", "default-hasher", "inline-more", "equivalent"] }
1617
oxilangtag = { version = "0.1.5", features = ["serialize"], default-features = false }
1718
serde = { version = "1.0.137", features = ["derive"], default-features = false }
1819
serde_json = { version = "1.0.81", default-features = false }

deny.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,4 +8,4 @@ multiple-versions = "deny"
88
version = 2
99
# We want really high confidence when inferring licenses from text
1010
confidence-threshold = 0.93
11-
allow = ["Apache-2.0", "MIT", "Unicode-DFS-2016"]
11+
allow = ["Apache-2.0", "MIT", "Unicode-DFS-2016", "Zlib", "Unicode-3.0"]

src/builder.rs

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -206,8 +206,9 @@ pub mod affordance;
206206
pub mod data_schema;
207207
mod human_readable_info;
208208

209-
use std::{collections::HashMap, fmt, marker::PhantomData, ops::Not};
209+
use std::{fmt, marker::PhantomData, ops::Not};
210210

211+
use hashbrown::{hash_map::Entry, HashMap};
211212
use oxilangtag::LanguageTag;
212213
use serde_json::Value;
213214
use time::OffsetDateTime;
@@ -759,8 +760,6 @@ impl<Other: ExtendableThing, Status> ThingBuilder<Other, Status> {
759760
///
760761
/// This step will perform the final validation of the builder state.
761762
pub fn build(self) -> Result<Thing<Other>, Error> {
762-
use std::collections::hash_map::Entry;
763-
764763
let Self {
765764
context,
766765
id,
@@ -1696,8 +1695,6 @@ where
16961695
A: BuildableAffordance<Target = T>,
16971696
H: Fn(FormOperation) -> bool,
16981697
{
1699-
use std::collections::hash_map::Entry;
1700-
17011698
affordances
17021699
.is_empty()
17031700
.not()

src/builder/affordance.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,9 @@
55
//!
66
//! See the examples related to the specific affordance bulders for more information.
77
8-
use std::{collections::HashMap, ops::Not};
8+
use std::ops::Not;
99

10+
use hashbrown::HashMap;
1011
use serde_json::Value;
1112

1213
use crate::{

src/builder/data_schema.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,9 @@
3939
//! [`finish_extend`]: DataSchemaBuilder::finish_extend
4040
//! [`read_only`]: crate::thing::DataSchema::read_only
4141
//! [`write_only`]: crate::thing::DataSchema::write_only
42-
use std::{cmp::Ordering, collections::HashMap, marker::PhantomData, num::NonZeroU64, ops::Not};
42+
use std::{cmp::Ordering, marker::PhantomData, num::NonZeroU64, ops::Not};
43+
44+
use hashbrown::HashMap;
4345

4446
use crate::{
4547
extend::{Extend, Extendable, ExtendableThing},

src/thing.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,11 @@
1010
use std::{
1111
borrow::Cow,
1212
cmp::{self, Ordering},
13-
collections::HashMap,
1413
fmt,
1514
num::NonZeroU64,
1615
};
1716

17+
use hashbrown::HashMap;
1818
use oxilangtag::LanguageTag;
1919
use serde::{Deserialize, Deserializer, Serialize, Serializer};
2020
use serde_json::Value;

0 commit comments

Comments
 (0)