aboutsummaryrefslogtreecommitdiff
path: root/delta_write_select.go
diff options
context:
space:
mode:
authorGravatar Runxi Yu2026-02-20 12:51:16 +0800
committerGravatar Runxi Yu2026-02-20 12:57:31 +0800
commit9730560a82426408243cb15349f6955a4ba34f60 (patch)
tree00cfcfc75db7b1de795b822f70246abd40199b86 /delta_write_select.go
parentRevert "packed: Use random delta seed" (diff)
signatureNo signature
Revert "packed: Write packs with deltas"
This reverts commit 17c9aee0e781026353ead4ac749a3ae89c83d007.
Diffstat (limited to 'delta_write_select.go')
-rw-r--r--delta_write_select.go56
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
-}