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

Function IsDiffSmaller

internal/diff/diff.go:45–50  ·  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

43// than storing the full content. Returns false for near-complete rewrites
44// where the diff is >= 80% of the full content size.
45func IsDiffSmaller(patch, fullContent string) bool {
46 if len(fullContent) == 0 {
47 return false
48 }
49 return len(patch) < (len(fullContent) * 80 / 100)
50}
51
52// CreateReversePatch computes a patch that transforms newText back into oldText.
53// Used for reverse-diff version storage: current doc has latest content,

Callers 4

UpdateDocumentMethod · 0.92
TestIsDiffSmallerFunction · 0.85

Calls

no outgoing calls

Tested by 2

TestIsDiffSmallerFunction · 0.68