[PATCH] [Support] Add MemoryBuffer::getFileSlice()
Rafael Ávila de Espíndola
rafael.espindola at gmail.com
Tue Oct 7 14:43:39 PDT 2014
Comment at: include/llvm/Support/MemoryBuffer.h:131
@@ +130,3 @@
+ static ErrorOr<std::unique_ptr<MemoryBuffer>>
+ getFileSlice(const Twine &Filename, uint64_t Offset, uint64_t Length);
Pass MapSize before Offset.
Alternatively, update getOpenFileSlice to have this order/name. My only preference is that they match.
Comment at: lib/Support/MemoryBuffer.cpp:335
@@ -327,1 +334,3 @@
+ // If we don't know the file size, use fstat to find out. fstat on an open
+ // file descriptor is cheaper than stat on a random path.
Why was it necessary to move this?
Currently if the user passes the MapSize and we don't require a null terminator, we never call stat in here, since we don't need the file size.
I now notice that we call stat in mapped_file_region, which is a regression from when we transitioned to mapped_file_region :-(
In any case , if we can avoid an extra stat we should.
More information about the llvm-commits