diff: remove some empty ins/del instructions

This commit is contained in:
mappu 2017-07-11 18:07:55 +12:00
parent 7c0a7af05f
commit 1938e659ab

View File

@ -49,6 +49,12 @@ func Diff(o, n []string) []Instruction {
if len(o) == 0 && len(n) == 0 { if len(o) == 0 && len(n) == 0 {
return []Instruction{} return []Instruction{}
} }
if len(o) == 0 {
return []Instruction{{OP_INSERTED, n}}
}
if len(n) == 0 {
return []Instruction{{OP_REMOVED, o}}
}
maxl := 0 maxl := 0
omax := 0 omax := 0
@ -79,8 +85,8 @@ func Diff(o, n []string) []Instruction {
if maxl == 0 { if maxl == 0 {
return []Instruction{ return []Instruction{
Instruction{OP_REMOVED, o}, {OP_REMOVED, o},
Instruction{OP_INSERTED, n}, {OP_INSERTED, n},
} }
} }