Skip to content

Commit a23a0c0

Browse files
committed
Use immutable references when possible
1 parent 5d468d9 commit a23a0c0

File tree

4 files changed

+7
-7
lines changed

4 files changed

+7
-7
lines changed

src/branchrule.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -225,11 +225,11 @@ mod tests {
225225

226226
let vars = model.vars();
227227
model.add_cons_node(
228-
child1,
229-
cons().eq(0.0).coef(&vars[0], 1.).coef(&vars[1], -1.),
228+
&child1,
229+
&cons().eq(0.0).coef(&vars[0], 1.).coef(&vars[1], -1.),
230230
);
231231

232-
model.add_cons_node(child2, cons().eq(1.0).coef(&vars[0], 1.).coef(&vars[1], 1.));
232+
model.add_cons_node(&child2, &cons().eq(1.0).coef(&vars[0], 1.).coef(&vars[1], 1.));
233233

234234
// model.add_cons_node(child1, vec![&vars[0], &vars[1]], &[1., -1.], 0., 0., "eq");
235235
// model.add_cons_node(child2, vec![&vars[0], &vars[1]], &[1., 1.], 0., 1., "diff");

src/model.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -501,7 +501,7 @@ impl Model<Solving> {
501501
/// # Panics
502502
///
503503
/// This method panics if the constraint cannot be created in the current state.
504-
pub fn add_cons_local(&mut self, cons_builder: ConsBuilder) -> Constraint {
504+
pub fn add_cons_local(&mut self, cons_builder: &ConsBuilder) -> Constraint {
505505
let vars: Vec<&Variable> = cons_builder.coefs.iter().map(|(var, _)| *var).collect();
506506
let coefs: Vec<f64> = cons_builder.coefs.iter().map(|(_, coef)| *coef).collect();
507507

@@ -537,7 +537,7 @@ impl Model<Solving> {
537537
/// # Panics
538538
///
539539
/// This method panics if the constraint cannot be created in the current state.
540-
pub fn add_cons_node(&mut self, node: Node, cons_builder: ConsBuilder) -> Constraint {
540+
pub fn add_cons_node(&mut self, node: &Node, cons_builder: &ConsBuilder) -> Constraint {
541541
let vars: Vec<&Variable> = cons_builder.coefs.iter().map(|(var, _)| *var).collect();
542542
let coefs: Vec<f64> = cons_builder.coefs.iter().map(|(_, coef)| *coef).collect();
543543

src/scip.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -354,7 +354,7 @@ impl ScipPtr {
354354

355355
pub(crate) fn create_cons(
356356
&self,
357-
node: Option<Node>,
357+
node: Option<&Node>,
358358
vars: Vec<&Variable>,
359359
coefs: &[f64],
360360
lhs: f64,

src/separator.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -292,7 +292,7 @@ mod tests {
292292
}
293293
model.add_cut(row, true);
294294

295-
model.add_cons_local(cons().ge(7.0).coef(&(vars[0]), 2.).coef(&(vars[1]), 1.));
295+
model.add_cons_local(&cons().ge(7.0).coef(&(vars[0]), 2.).coef(&(vars[1]), 1.));
296296

297297
SeparationResult::Separated
298298
}

0 commit comments

Comments
 (0)