mirror of
https://github.com/gitleaks/gitleaks.git
synced 2026-12-01 21:44:23 +01:00
single commit and bumping go-git version
This commit is contained in:
1 parent
3b45fb91e3
commit
15dedda59a
48 files changed
+1453
-390
No files matched your search
+12
-12
@@ -45,19 +45,23 @@ func (c *BufferLRU) Put(key int64, slice []byte) {
|
||||
c.ll = list.New()
|
||||
}
|
||||
|
||||
bufSize := FileSize(len(slice))
|
||||
if ee, ok := c.cache[key]; ok {
|
||||
oldBuf := ee.Value.(buffer)
|
||||
// in this case bufSize is a delta: new size - old size
|
||||
bufSize -= FileSize(len(oldBuf.Slice))
|
||||
c.ll.MoveToFront(ee)
|
||||
ee.Value = buffer{key, slice}
|
||||
return
|
||||
} else {
|
||||
if bufSize > c.MaxSize {
|
||||
return
|
||||
}
|
||||
ee := c.ll.PushFront(buffer{key, slice})
|
||||
c.cache[key] = ee
|
||||
}
|
||||
|
||||
objSize := FileSize(len(slice))
|
||||
|
||||
if objSize > c.MaxSize {
|
||||
return
|
||||
}
|
||||
|
||||
for c.actualSize+objSize > c.MaxSize {
|
||||
c.actualSize += bufSize
|
||||
for c.actualSize > c.MaxSize {
|
||||
last := c.ll.Back()
|
||||
lastObj := last.Value.(buffer)
|
||||
lastSize := FileSize(len(lastObj.Slice))
|
||||
@@ -66,10 +70,6 @@ func (c *BufferLRU) Put(key int64, slice []byte) {
|
||||
delete(c.cache, lastObj.Key)
|
||||
c.actualSize -= lastSize
|
||||
}
|
||||
|
||||
ee := c.ll.PushFront(buffer{key, slice})
|
||||
c.cache[key] = ee
|
||||
c.actualSize += objSize
|
||||
}
|
||||
|
||||
// Get returns a buffer by its key. It marks the buffer as used. If the buffer
|
||||
|
||||
+12
-12
@@ -42,20 +42,24 @@ func (c *ObjectLRU) Put(obj plumbing.EncodedObject) {
|
||||
c.ll = list.New()
|
||||
}
|
||||
|
||||
objSize := FileSize(obj.Size())
|
||||
key := obj.Hash()
|
||||
if ee, ok := c.cache[key]; ok {
|
||||
oldObj := ee.Value.(plumbing.EncodedObject)
|
||||
// in this case objSize is a delta: new size - old size
|
||||
objSize -= FileSize(oldObj.Size())
|
||||
c.ll.MoveToFront(ee)
|
||||
ee.Value = obj
|
||||
return
|
||||
} else {
|
||||
if objSize > c.MaxSize {
|
||||
return
|
||||
}
|
||||
ee := c.ll.PushFront(obj)
|
||||
c.cache[key] = ee
|
||||
}
|
||||
|
||||
objSize := FileSize(obj.Size())
|
||||
|
||||
if objSize > c.MaxSize {
|
||||
return
|
||||
}
|
||||
|
||||
for c.actualSize+objSize > c.MaxSize {
|
||||
c.actualSize += objSize
|
||||
for c.actualSize > c.MaxSize {
|
||||
last := c.ll.Back()
|
||||
lastObj := last.Value.(plumbing.EncodedObject)
|
||||
lastSize := FileSize(lastObj.Size())
|
||||
@@ -64,10 +68,6 @@ func (c *ObjectLRU) Put(obj plumbing.EncodedObject) {
|
||||
delete(c.cache, lastObj.Hash())
|
||||
c.actualSize -= lastSize
|
||||
}
|
||||
|
||||
ee := c.ll.PushFront(obj)
|
||||
c.cache[key] = ee
|
||||
c.actualSize += objSize
|
||||
}
|
||||
|
||||
// Get returns an object by its hash. It marks the object as used. If the object
|
||||
|
||||
Reference in new issue
Block a user