Skip to content

Commit

Permalink
refactor: unify history and memory in partial_solution (#92)
Browse files Browse the repository at this point in the history
* refactor: unify history and memory in partial_solution

* refactor: use retain

* refactor: use partition_point

* perf: use more SmallVec

Co-authored-by: Jacob Finkelman <[email protected]>
  • Loading branch information
mpizenberg and Eh2406 authored Jun 6, 2021
1 parent 2459aa4 commit cd91684
Show file tree
Hide file tree
Showing 6 changed files with 363 additions and 382 deletions.
52 changes: 0 additions & 52 deletions src/internal/assignment.rs

This file was deleted.

7 changes: 3 additions & 4 deletions src/internal/core.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,8 @@ use std::collections::HashSet as Set;

use crate::error::PubGrubError;
use crate::internal::arena::Arena;
use crate::internal::assignment::Assignment::{Decision, Derivation};
use crate::internal::incompatibility::IncompId;
use crate::internal::incompatibility::{Incompatibility, Relation};
use crate::internal::incompatibility::{IncompId, Incompatibility, Relation};
use crate::internal::partial_solution::Assignment::{Decision, Derivation};
use crate::internal::partial_solution::{DecisionLevel, PartialSolution};
use crate::internal::small_vec::SmallVec;
use crate::package::Package;
Expand Down Expand Up @@ -175,7 +174,7 @@ impl<P: Package, V: Version> State<P, V> {
&self.incompatibility_store[current_incompat_id],
&self.incompatibility_store,
);
match satisfier.clone() {
match satisfier {
Decision { package, .. } => {
self.backtrack(
current_incompat_id,
Expand Down
7 changes: 1 addition & 6 deletions src/internal/incompatibility.rs
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ enum Kind<P: Package, V: Version> {

/// A Relation describes how a set of terms can be compared to an incompatibility.
/// Typically, the set of terms comes from the partial solution.
#[derive(Eq, PartialEq)]
#[derive(Eq, PartialEq, Debug)]
pub enum Relation<P: Package> {
/// We say that a set of terms S satisfies an incompatibility I
/// if S satisfies every term in I.
Expand Down Expand Up @@ -166,11 +166,6 @@ impl<P: Package, V: Version> Incompatibility<P, V> {
self.package_terms.iter()
}

// The number of packages.
pub fn len(&self) -> usize {
self.package_terms.len()
}

// Reporting ###############################################################

/// Retrieve parent causes if of type DerivedFrom.
Expand Down
164 changes: 0 additions & 164 deletions src/internal/memory.rs

This file was deleted.

2 changes: 0 additions & 2 deletions src/internal/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,8 @@
//! Non exposed modules.
pub mod arena;
pub mod assignment;
pub mod core;
pub mod incompatibility;
pub mod memory;
pub mod partial_solution;
pub mod small_map;
pub mod small_vec;
Loading

0 comments on commit cd91684

Please sign in to comment.