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,6 +901,17 @@ func (p *blockBodyDiffPrinter) writeValueDiff(old, new cty.Value, indent int, pa
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Optimization for strings which are exactly equal: just print
|
||||||
|
// directly without calculating the sequence diff. This makes a
|
||||||
|
// significant difference when this code path is reached via a
|
||||||
|
// writeValue call with a large multi-line string.
|
||||||
|
if oldS == newS {
|
||||||
|
for _, line := range newLines {
|
||||||
|
p.buf.WriteString(strings.Repeat(" ", indent+4))
|
||||||
|
p.buf.WriteString(line.AsString())
|
||||||
|
p.buf.WriteString("\n")
|
||||||
|
}
|
||||||
|
} else {
|
||||||
diffLines := ctySequenceDiff(oldLines, newLines)
|
diffLines := ctySequenceDiff(oldLines, newLines)
|
||||||
for _, diffLine := range diffLines {
|
for _, diffLine := range diffLines {
|
||||||
p.buf.WriteString(strings.Repeat(" ", indent+2))
|
p.buf.WriteString(strings.Repeat(" ", indent+2))
|
||||||
@ -919,6 +930,7 @@ func (p *blockBodyDiffPrinter) writeValueDiff(old, new cty.Value, indent int, pa
|
|||||||
}
|
}
|
||||||
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
|
||||||
p.buf.WriteString("EOT")
|
p.buf.WriteString("EOT")
|
||||||
|
Loading…
Reference in New Issue
Block a user