Commit bc14f1d
Improve ldiff binary files detection
The former code was performing scan on the first 4K of each file to see
if one of them has a '\0' char in it and consider it as a binary file.
This commit does not change this heuristic just the implementation.
Instead of using the scan method with a regexp, use a simple include?.
This not only fix compatibility issues with UTF8 escape sequences, but
also the performance:
1. it does not leverage a Regexp system.
2. it stops at first occurence worst case is O(n).
3. it does not store much.
Also instead of using .empty? which would signal a non-binary file, the
call to include? invert the boolean test.
IMHO it is clearer.
Note: this could have been achieved simply by replacing .empty by .any?
but the other improvements listed above motivated the change.1 parent fec781d commit bc14f1d
1 file changed
+3
-3
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
104 | 104 | | |
105 | 105 | | |
106 | 106 | | |
107 | | - | |
108 | | - | |
109 | | - | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
110 | 110 | | |
111 | 111 | | |
112 | 112 | | |
| |||
0 commit comments