diff options
author | Rafael Espindola <rafael.espindola@gmail.com> | 2014-12-12 18:13:23 +0000 |
---|---|---|
committer | Rafael Espindola <rafael.espindola@gmail.com> | 2014-12-12 18:13:23 +0000 |
commit | c69f13bfe1b7c0f663ea204f6e961d669f4bab02 (patch) | |
tree | 799e8c7483b1f2a83d663ee849f6a473ceb41204 /llvm/unittests/Support/Path.cpp | |
parent | 555a7a6ad2267c196993839930e962588a1f62d0 (diff) | |
download | llvm-c69f13bfe1b7c0f663ea204f6e961d669f4bab02.zip llvm-c69f13bfe1b7c0f663ea204f6e961d669f4bab02.tar.gz llvm-c69f13bfe1b7c0f663ea204f6e961d669f4bab02.tar.bz2 |
Move the resize file feature from mapped_file_region to the only user.
This removes a duplicated stat on every file that llvm-ar looks at.
llvm-svn: 224138
Diffstat (limited to 'llvm/unittests/Support/Path.cpp')
-rw-r--r-- | llvm/unittests/Support/Path.cpp | 9 |
1 files changed, 6 insertions, 3 deletions
diff --git a/llvm/unittests/Support/Path.cpp b/llvm/unittests/Support/Path.cpp index 88baade..0d661c8a 100644 --- a/llvm/unittests/Support/Path.cpp +++ b/llvm/unittests/Support/Path.cpp @@ -654,12 +654,15 @@ TEST_F(FileSystemTest, FileMapping) { SmallString<64> TempPath; ASSERT_NO_ERROR( fs::createTemporaryFile("prefix", "temp", FileDescriptor, TempPath)); + unsigned Size = 4096; + ASSERT_NO_ERROR(fs::resize_file(FileDescriptor, Size)); + // Map in temp file and add some content std::error_code EC; StringRef Val("hello there"); { fs::mapped_file_region mfr(FileDescriptor, - fs::mapped_file_region::readwrite, 4096, 0, EC); + fs::mapped_file_region::readwrite, Size, 0, EC); ASSERT_NO_ERROR(EC); std::copy(Val.begin(), Val.end(), mfr.data()); // Explicitly add a 0. @@ -671,14 +674,14 @@ TEST_F(FileSystemTest, FileMapping) { int FD; EC = fs::openFileForRead(Twine(TempPath), FD); ASSERT_NO_ERROR(EC); - fs::mapped_file_region mfr(FD, fs::mapped_file_region::readonly, 0, 0, EC); + fs::mapped_file_region mfr(FD, fs::mapped_file_region::readonly, Size, 0, EC); ASSERT_NO_ERROR(EC); // Verify content EXPECT_EQ(StringRef(mfr.const_data()), Val); // Unmap temp file - fs::mapped_file_region m(FD, fs::mapped_file_region::readonly, 0, 0, EC); + fs::mapped_file_region m(FD, fs::mapped_file_region::readonly, Size, 0, EC); ASSERT_NO_ERROR(EC); ASSERT_EQ(close(FD), 0); } |