@@ -24,20 +24,20 @@ import {
2424const SYSTEM_KEYS = [ '_id' , '_type' , '_createdAt' , '_updatedAt' , '_rev' ]
2525
2626/**
27- * Maximum document size to consider for diff-match-patch (1MB)
28- * Based on testing showing consistent 0-2ms performance up to this size
27+ * Maximum size of strings to consider for diff-match-patch (1MB)
28+ * Based on testing showing consistently good performance up to this size
2929 */
30- const DMP_MAX_DOCUMENT_SIZE = 1_000_000
30+ const DMP_MAX_STRING_SIZE = 1_000_000
3131
3232/**
33- * Maximum change ratio before falling back to set operations (40%)
33+ * Maximum difference in string length before falling back to set operations (40%)
3434 * Above this threshold, likely indicates text replacement which can be slow
3535 */
36- const DMP_MAX_CHANGE_RATIO = 0.4
36+ const DMP_MAX_STRING_LENGTH_CHANGE_RATIO = 0.4
3737
3838/**
39- * Minimum document size to apply change ratio check (10KB)
40- * Small documents are always fast regardless of change ratio
39+ * Minimum string size to apply change ratio check (10KB)
40+ * Small strings are always fast regardless of change ratio
4141 */
4242const DMP_MIN_SIZE_FOR_RATIO_CHECK = 10_000
4343
@@ -405,8 +405,6 @@ function diffArrayByKey(
405405 * Compatible with @sanity/diff-match-patch@3.2.0
406406 */
407407export function shouldUseDiffMatchPatch ( source : string , target : string ) : boolean {
408- // const sourceLength = sourceText.length
409- // const targetLength = targetText.length
410408 const maxLength = Math . max ( source . length , target . length )
411409
412410 // Always reject documents larger than our tested size limit
0 commit comments