MCPcopy Create free account
hub / github.com/PerpetualSoftware/pad / IsDiffSmaller

Function IsDiffSmaller

internal/diff/diff.go:105–110  ·  view source on GitHub ↗

IsDiffSmaller returns true if storing a diff would be meaningfully smaller than storing the full content. Returns false for near-complete rewrites where the diff is >= 80% of the full content size.

(patch, fullContent string)

Source from the content-addressed store, hash-verified

103// than storing the full content. Returns false for near-complete rewrites
104// where the diff is >= 80% of the full content size.
105func IsDiffSmaller(patch, fullContent string) bool {
106 if len(fullContent) == 0 {
107 return false
108 }
109 return len(patch) < (len(fullContent) * 80 / 100)
110}
111
112// CreateReversePatch computes a patch that transforms newText back into oldText.
113// Used for reverse-diff version storage: current doc has latest content,

Callers 6

UpdateDocumentMethod · 0.92
planVersionChainRemapFunction · 0.92
TestIsDiffSmallerFunction · 0.85

Calls

no outgoing calls

Tested by 2

TestIsDiffSmallerFunction · 0.68