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