diff options
| author | 2026-02-20 12:51:16 +0800 | |
|---|---|---|
| committer | 2026-02-20 12:57:31 +0800 | |
| commit | 9730560a82426408243cb15349f6955a4ba34f60 (patch) | |
| tree | 00cfcfc75db7b1de795b822f70246abd40199b86 /delta_write_select.go | |
| parent | Revert "packed: Use random delta seed" (diff) | |
| signature | No signature | |
Revert "packed: Write packs with deltas"
This reverts commit 17c9aee0e781026353ead4ac749a3ae89c83d007.
Diffstat (limited to 'delta_write_select.go')
| -rw-r--r-- | delta_write_select.go | 56 |
1 files changed, 0 insertions, 56 deletions
diff --git a/delta_write_select.go b/delta_write_select.go deleted file mode 100644 index ad8e0d0e..00000000 --- a/delta_write_select.go +++ /dev/null @@ -1,56 +0,0 @@ -package furgit - -const defaultDeltaWindow = 64 - -type objectToPack struct { - id Hash - ty ObjectType - body []byte - offset uint64 - deltaDepth int -} - -type deltaContext struct { - window int - candidates []*objectToPack -} - -func (ctx *deltaContext) addCandidate(obj *objectToPack) { - if ctx.window <= 0 { - return - } - ctx.candidates = append(ctx.candidates, obj) - if len(ctx.candidates) > ctx.window { - over := len(ctx.candidates) - ctx.window - ctx.candidates = ctx.candidates[over:] - } -} - -func pickDeltaBase(ctx *deltaContext, obj *objectToPack, seed uint32, minSavings, maxDepth int) (*objectToPack, []byte) { - if ctx == nil || len(ctx.candidates) == 0 { - return nil, nil - } - if maxDepth <= 0 { - maxDepth = 1 - } - var bestBase *objectToPack - var bestDelta []byte - for i := len(ctx.candidates) - 1; i >= 0; i-- { - base := ctx.candidates[i] - if base.ty != ObjectTypeBlob { - continue - } - if base.deltaDepth >= maxDepth { - continue - } - delta, ok := deltaTry(base.body, obj.body, seed, minSavings) - if !ok { - continue - } - if bestDelta == nil || len(delta) < len(bestDelta) { - bestDelta = delta - bestBase = base - } - } - return bestBase, bestDelta -} |
