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)
| 103 | // than storing the full content. Returns false for near-complete rewrites |
| 104 | // where the diff is >= 80% of the full content size. |
| 105 | func 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, |
no outgoing calls