diff options
| author | Nikhil Kalra <nkalra@apple.com> | 2025-02-12 14:17:30 -0800 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2025-02-12 14:17:30 -0800 |
| commit | f3a29906aa07d08bbde7ec02b93d02e25d805110 (patch) | |
| tree | cf2ce7560e0eb477da2b5a0659dae4b0bea4beec /mlir/lib/Bytecode | |
| parent | ceb00c07028491506bcf8e334bb12cab7792098f (diff) | |
[mlir] BytecodeWriter: invoke `reserveExtraSpace` (#126953)
Update `BytecodeWriter` to invoke `reserveExtraSpace` on the stream
before writing to it. This will give clients implementing custom output
streams the opportunity to allocate an appropriately sized buffer for
the write.
Diffstat (limited to 'mlir/lib/Bytecode')
| -rw-r--r-- | mlir/lib/Bytecode/Writer/BytecodeWriter.cpp | 3 |
1 files changed, 3 insertions, 0 deletions
diff --git a/mlir/lib/Bytecode/Writer/BytecodeWriter.cpp b/mlir/lib/Bytecode/Writer/BytecodeWriter.cpp index 2b4697434717..cc5aaed41651 100644 --- a/mlir/lib/Bytecode/Writer/BytecodeWriter.cpp +++ b/mlir/lib/Bytecode/Writer/BytecodeWriter.cpp @@ -613,6 +613,9 @@ private: } // namespace void EncodingEmitter::writeTo(raw_ostream &os) const { + // Reserve space in the ostream for the encoded contents. + os.reserveExtraSpace(size()); + for (auto &prevResult : prevResultList) os.write((const char *)prevResult.data(), prevResult.size()); os.write((const char *)currentResult.data(), currentResult.size()); |
