Skip to content

Commit ab8ba5c

Browse files
committed
Use smallvec crate in pubgrub
1 parent ff73786 commit ab8ba5c

File tree

6 files changed

+12
-241
lines changed

6 files changed

+12
-241
lines changed

Cargo.lock

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ log = "0.4.22" # for debug logs in tests
2828
priority-queue = "2.1.1"
2929
rustc-hash = ">=1.0.0, <3.0.0"
3030
serde = { version = "1.0", features = ["derive"], optional = true }
31+
smallvec = { version = "1.13.2", features = ["union"] }
3132
thiserror = "1.0"
3233
version-ranges = { version = "0.1.0", path = "version-ranges" }
3334

src/internal/core.rs

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,12 @@
55
66
use std::sync::Arc;
77

8+
use smallvec::SmallVec;
9+
810
use crate::{
911
internal::{
1012
Arena, DecisionLevel, IncompDpId, Incompatibility, PartialSolution, Relation,
11-
SatisfierSearch, SmallVec,
13+
SatisfierSearch,
1214
},
1315
DependencyProvider, DerivationTree, Map, Package, PackageArena, Set, Term, Version, VersionSet,
1416
};
@@ -25,7 +27,7 @@ pub(crate) struct State<DP: DependencyProvider> {
2527
/// All incompatibilities expressing dependencies,
2628
/// with common dependents merged.
2729
#[allow(clippy::type_complexity)]
28-
merged_dependencies: Map<(Package, Package), SmallVec<IncompDpId<DP>>>,
30+
merged_dependencies: Map<(Package, Package), SmallVec<[IncompDpId<DP>; 4]>>,
2931

3032
/// Partial solution.
3133
/// TODO: remove pub.
@@ -37,7 +39,7 @@ pub(crate) struct State<DP: DependencyProvider> {
3739
/// This is a stack of work to be done in `unit_propagation`.
3840
/// It can definitely be a local variable to that method, but
3941
/// this way we can reuse the same allocation for better performance.
40-
unit_propagation_buffer: SmallVec<Package>,
42+
unit_propagation_buffer: Vec<Package>,
4143
}
4244

4345
impl<DP: DependencyProvider> State<DP> {
@@ -54,7 +56,7 @@ impl<DP: DependencyProvider> State<DP> {
5456
incompatibilities,
5557
partial_solution: PartialSolution::empty(),
5658
incompatibility_store,
57-
unit_propagation_buffer: SmallVec::Empty,
59+
unit_propagation_buffer: Vec::new(),
5860
merged_dependencies: Map::default(),
5961
}
6062
}

src/internal/mod.rs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,9 @@ mod core;
77
mod incompatibility;
88
mod partial_solution;
99
mod small_map;
10-
mod small_vec;
1110

1211
pub(crate) use arena::{Arena, Id};
1312
pub(crate) use core::State;
1413
pub(crate) use incompatibility::{IncompDpId, IncompId, Incompatibility, Relation};
1514
pub(crate) use partial_solution::{DecisionLevel, PartialSolution, SatisfierSearch};
1615
pub(crate) use small_map::SmallMap;
17-
pub(crate) use small_vec::SmallVec;

src/internal/partial_solution.rs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,10 @@ use std::hash::BuildHasherDefault;
88

99
use priority_queue::PriorityQueue;
1010
use rustc_hash::FxHasher;
11+
use smallvec::{smallvec, SmallVec};
1112

1213
use crate::{
13-
internal::{Arena, IncompDpId, IncompId, Incompatibility, Relation, SmallMap, SmallVec},
14+
internal::{Arena, IncompDpId, IncompId, Incompatibility, Relation, SmallMap},
1415
DependencyProvider, FxIndexMap, Package, PackageArena, SelectedDependencies, Term, Version,
1516
VersionSet,
1617
};
@@ -97,7 +98,7 @@ impl<'a, DP: DependencyProvider> Display for PartialSolutionDisplay<'a, DP> {
9798
struct PackageAssignments<M: Clone + Debug + Display> {
9899
smallest_decision_level: DecisionLevel,
99100
highest_decision_level: DecisionLevel,
100-
dated_derivations: SmallVec<DatedDerivation<M>>,
101+
dated_derivations: SmallVec<[DatedDerivation<M>; 1]>,
101102
assignments_intersection: AssignmentsIntersection,
102103
}
103104

@@ -298,7 +299,7 @@ impl<DP: DependencyProvider> PartialSolution<DP> {
298299
v.insert(PackageAssignments {
299300
smallest_decision_level: self.current_decision_level,
300301
highest_decision_level: self.current_decision_level,
301-
dated_derivations: SmallVec::One([dated_derivation]),
302+
dated_derivations: smallvec![dated_derivation],
302303
assignments_intersection: AssignmentsIntersection::derivations(term),
303304
});
304305
}

src/internal/small_vec.rs

Lines changed: 0 additions & 232 deletions
This file was deleted.

0 commit comments

Comments
 (0)