mirror of
https://github.com/pmezard/go-difflib.git
synced 2026-04-01 17:17:09 +09:00
difflib: optimize SplitLines
This commit is contained in:
@@ -752,9 +752,7 @@ func GetContextDiffString(diff ContextDiff) (string, error) {
|
||||
// Split a string on "\n" while preserving them. The output can be used
|
||||
// as input for UnifiedDiff and ContextDiff structures.
|
||||
func SplitLines(s string) []string {
|
||||
lines := []string{}
|
||||
for _, line := range strings.Split(s, "\n") {
|
||||
lines = append(lines, line+"\n")
|
||||
}
|
||||
lines := strings.SplitAfter(s, "\n")
|
||||
lines[len(lines)-1] += "\n"
|
||||
return lines
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user