@@ -147,7 +147,7 @@ func (p *Pigosat) isValid() bool {
147147// sure, it's always safe to call Delete again). Most users will not need this
148148// method.
149149func (p * Pigosat ) Delete () {
150- if p == nil || p . p == nil {
150+ if ! p . isValid () {
151151 return
152152 }
153153 p .lock .Lock ()
@@ -164,7 +164,7 @@ func (p *Pigosat) Delete() {
164164// Variables returns the number of variables in the formula: The m in the DIMACS
165165// header "p cnf <m> n".
166166func (p * Pigosat ) Variables () int {
167- if p == nil || p . p == nil {
167+ if ! p . isValid () {
168168 return 0
169169 }
170170 p .lock .RLock ()
@@ -176,7 +176,7 @@ func (p *Pigosat) Variables() int {
176176// AddedOriginalClauses returns the number of clauses in the formula: The n in
177177// the DIMACS header "p cnf m <n>".
178178func (p * Pigosat ) AddedOriginalClauses () int {
179- if p == nil || p . p == nil {
179+ if ! p . isValid () {
180180 return 0
181181 }
182182 p .lock .RLock ()
@@ -187,7 +187,7 @@ func (p *Pigosat) AddedOriginalClauses() int {
187187
188188// Seconds returns the time spent in the PicoSAT library.
189189func (p * Pigosat ) Seconds () time.Duration {
190- if p == nil || p . p == nil {
190+ if ! p . isValid () {
191191 return 0
192192 }
193193 p .lock .RLock ()
@@ -205,7 +205,7 @@ func (p *Pigosat) Seconds() time.Duration {
205205// the clause, and causes AddClauses to skip reading the rest of the slice. Nil
206206// slices are ignored and skipped.
207207func (p * Pigosat ) AddClauses (clauses [][]int32 ) {
208- if p == nil || p . p == nil {
208+ if ! p . isValid () {
209209 return
210210 }
211211 p .lock .Lock ()
@@ -247,7 +247,7 @@ func (p *Pigosat) blocksol(sol []bool) {
247247// // Do stuff with status, solution
248248// }
249249func (p * Pigosat ) Solve () (status int , solution []bool ) {
250- if p == nil || p . p == nil {
250+ if ! p . isValid () {
251251 return NotReady , nil
252252 }
253253 p .lock .Lock ()
@@ -280,7 +280,7 @@ func (p *Pigosat) Solve() (status int, solution []bool) {
280280// length. There is no need to call BlockSolution after calling Pigosat.Solve,
281281// which calls it automatically for every Satisfiable solution.
282282func (p * Pigosat ) BlockSolution (solution []bool ) error {
283- if p == nil || p . p == nil {
283+ if ! p . isValid () {
284284 return nil
285285 }
286286 p .lock .Lock ()
0 commit comments