slightly optimize two way merge

This commit is contained in:
fyears 2024-07-13 23:19:39 +08:00
parent 7228398d0a
commit f256936bae

View File

@ -73,6 +73,18 @@ function getLCSText(a: string, b: string) {
* @returns * @returns
*/ */
function twoWayMerge(a: string, b: string): string { function twoWayMerge(a: string, b: string): string {
const aa = a.trim();
const bb = b.trim();
if (aa === "" && bb === "") {
return aa.length >= bb.length ? a : b;
}
if (bb === "") {
return a;
}
if (aa === "") {
return b;
}
// const c = getLCSText(a, b); // const c = getLCSText(a, b);
// const patches = makePatches(c, a); // const patches = makePatches(c, a);
// const [d] = applyPatches(patches, b); // const [d] = applyPatches(patches, b);