mirror of
https://github.com/mudler/luet.git
synced 2025-09-04 08:45:40 +00:00
update vendor/
This commit is contained in:
29
vendor/github.com/crillab/gophersat/solver/clause_alloc.go
generated
vendored
Normal file
29
vendor/github.com/crillab/gophersat/solver/clause_alloc.go
generated
vendored
Normal file
@@ -0,0 +1,29 @@
|
||||
package solver
|
||||
|
||||
// This file deals with an attempt for an efficient clause allocator/deallocator, to relax GC's work.
|
||||
|
||||
const (
|
||||
nbLitsAlloc = 5000000 // How many literals are initialized at first?
|
||||
)
|
||||
|
||||
type allocator struct {
|
||||
lits []Lit // A list of lits, that will be sliced to make []Lit
|
||||
ptrFree int // Index of the first free item in lits
|
||||
}
|
||||
|
||||
var alloc allocator
|
||||
|
||||
// newLits returns a slice of lits containing the given literals.
|
||||
// It is taken from the preinitialized pool if possible,
|
||||
// or is created from scratch.
|
||||
func (a *allocator) newLits(lits ...Lit) []Lit {
|
||||
if a.ptrFree+len(lits) > len(a.lits) {
|
||||
a.lits = make([]Lit, nbLitsAlloc)
|
||||
copy(a.lits, lits)
|
||||
a.ptrFree = len(lits)
|
||||
return a.lits[:len(lits)]
|
||||
}
|
||||
copy(a.lits[a.ptrFree:], lits)
|
||||
a.ptrFree += len(lits)
|
||||
return a.lits[a.ptrFree-len(lits) : a.ptrFree]
|
||||
}
|
Reference in New Issue
Block a user