This is an archive of the discontinued LLVM Phabricator instance.

Support: Extract sys::fs::readNativeFileToEOF() from MemoryBuffer
ClosedPublic

Authored by dexonsmith on Dec 8 2021, 1:48 PM.

Details

Summary

Extract the readNativeFile() loop from
MemoryBuffer::getMemoryBufferForStream() into readNativeFileToEOF()
to allow reuse. The chunk size is configurable; the default of 4*4096
is exposed as sys::fs::DefaultReadChunkSize to allow sizing of
SmallVectors.

There's somewhere I'd like to read a usually small file without overhead of a MemoryBuffer; extracting existing logic rather than duplicating it.

Test depends on https://reviews.llvm.org/D115395 (built on top of https://reviews.llvm.org/D115384, but they could be reordered...).

Diff Detail

Event Timeline

dexonsmith created this revision.Dec 8 2021, 1:48 PM
dexonsmith requested review of this revision.Dec 8 2021, 1:48 PM
Herald added a project: Restricted Project. · View Herald TranscriptDec 8 2021, 1:48 PM
dblaikie accepted this revision.Dec 9 2021, 11:54 AM

Sure, sounds good

This revision is now accepted and ready to land.Dec 9 2021, 11:54 AM
This revision was landed with ongoing or failed builds.Jan 11 2022, 6:06 PM
This revision was automatically updated to reflect the committed changes.