mirror of
https://github.com/opentofu/opentofu.git
synced 2025-02-25 18:45:20 -06:00
Merge pull request #27746 from hashicorp/alisdair/optimize-large-multi-line-string-outputs
cli: Optimize for large multi-line string outputs
This commit is contained in:
commit
04e512d2f9
@ -901,23 +901,35 @@ func (p *blockBodyDiffPrinter) writeValueDiff(old, new cty.Value, indent int, pa
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
diffLines := ctySequenceDiff(oldLines, newLines)
|
// Optimization for strings which are exactly equal: just print
|
||||||
for _, diffLine := range diffLines {
|
// directly without calculating the sequence diff. This makes a
|
||||||
p.buf.WriteString(strings.Repeat(" ", indent+2))
|
// significant difference when this code path is reached via a
|
||||||
p.writeActionSymbol(diffLine.Action)
|
// writeValue call with a large multi-line string.
|
||||||
|
if oldS == newS {
|
||||||
switch diffLine.Action {
|
for _, line := range newLines {
|
||||||
case plans.NoOp, plans.Delete:
|
p.buf.WriteString(strings.Repeat(" ", indent+4))
|
||||||
p.buf.WriteString(diffLine.Before.AsString())
|
p.buf.WriteString(line.AsString())
|
||||||
case plans.Create:
|
p.buf.WriteString("\n")
|
||||||
p.buf.WriteString(diffLine.After.AsString())
|
}
|
||||||
default:
|
} else {
|
||||||
// Should never happen since the above covers all
|
diffLines := ctySequenceDiff(oldLines, newLines)
|
||||||
// actions that ctySequenceDiff can return for strings
|
for _, diffLine := range diffLines {
|
||||||
p.buf.WriteString(diffLine.After.AsString())
|
p.buf.WriteString(strings.Repeat(" ", indent+2))
|
||||||
|
p.writeActionSymbol(diffLine.Action)
|
||||||
|
|
||||||
|
switch diffLine.Action {
|
||||||
|
case plans.NoOp, plans.Delete:
|
||||||
|
p.buf.WriteString(diffLine.Before.AsString())
|
||||||
|
case plans.Create:
|
||||||
|
p.buf.WriteString(diffLine.After.AsString())
|
||||||
|
default:
|
||||||
|
// Should never happen since the above covers all
|
||||||
|
// actions that ctySequenceDiff can return for strings
|
||||||
|
p.buf.WriteString(diffLine.After.AsString())
|
||||||
|
|
||||||
|
}
|
||||||
|
p.buf.WriteString("\n")
|
||||||
}
|
}
|
||||||
p.buf.WriteString("\n")
|
|
||||||
}
|
}
|
||||||
|
|
||||||
p.buf.WriteString(strings.Repeat(" ", indent)) // +4 here because there's no symbol
|
p.buf.WriteString(strings.Repeat(" ", indent)) // +4 here because there's no symbol
|
||||||
|
Loading…
Reference in New Issue
Block a user