mirror of
				https://github.com/flynx/diff.js.git
				synced 2025-10-31 12:00:09 +00:00 
			
		
		
		
	started building LCS into the diff loop...
Signed-off-by: Alex A. Naanou <alex.nanou@gmail.com>
This commit is contained in:
		
							parent
							
								
									28a1a43f1e
								
							
						
					
					
						commit
						93fe4412dd
					
				
							
								
								
									
										29
									
								
								diff.js
									
									
									
									
									
								
							
							
						
						
									
										29
									
								
								diff.js
									
									
									
									
									
								
							| @ -235,7 +235,6 @@ function(A, B, options){ | |||||||
| 	//		...would need to also include .value (i.e. .valueOf()) and 
 | 	//		...would need to also include .value (i.e. .valueOf()) and 
 | ||||||
| 	//		treat the thing as object...
 | 	//		treat the thing as object...
 | ||||||
| 	if(A === B || A == B){ | 	if(A === B || A == B){ | ||||||
| 	//if(A === B || (options.mode == 'JSON' && A == B)){
 |  | ||||||
| 		return null | 		return null | ||||||
| 	} | 	} | ||||||
| 
 | 
 | ||||||
| @ -261,9 +260,35 @@ function(A, B, options){ | |||||||
| 			function(a, b){ | 			function(a, b){ | ||||||
| 				// XXX cache _diff(..) results...
 | 				// XXX cache _diff(..) results...
 | ||||||
| 				return a === b || a == b || _diff(a, b) }) | 				return a === b || a == b || _diff(a, b) }) | ||||||
| 		// XXX diff only the sections that differ...
 | 		// collect gaps between common sections...
 | ||||||
|  | 		common_sections.shift() | ||||||
|  | 		var a = 0 | ||||||
|  | 		var b = 0 | ||||||
|  | 		var gaps = [] | ||||||
|  | 		common_sections | ||||||
|  | 			// make this consider the tail gap...
 | ||||||
|  | 			.concat({ | ||||||
|  | 				A: A.length, | ||||||
|  | 				B: B.length, | ||||||
|  | 				length: 0, | ||||||
|  | 			}) | ||||||
|  | 			.forEach(function(e){ | ||||||
|  | 				// store the gap...
 | ||||||
|  | 				a != e.A && b != e.B | ||||||
|  | 					&& gaps.push([ | ||||||
|  | 						[a, A.slice(a, e.A)], | ||||||
|  | 						[b: B.slice(b, e.B)], | ||||||
|  | 					]) | ||||||
|  | 				// go to next gap...
 | ||||||
|  | 				a = e.A + e.length | ||||||
|  | 				b = e.B + e.length | ||||||
|  | 			}) | ||||||
|  | 
 | ||||||
|  | 		// XXX diff the gaps...
 | ||||||
| 		// XXX
 | 		// XXX
 | ||||||
| 
 | 
 | ||||||
|  | 
 | ||||||
|  | 
 | ||||||
| 		// indexed items...
 | 		// indexed items...
 | ||||||
| 		_diff_items(res, A, B, options,  | 		_diff_items(res, A, B, options,  | ||||||
| 			function(e){ return e == 0 || !!(e*1) }) | 			function(e){ return e == 0 || !!(e*1) }) | ||||||
|  | |||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user