diff options
author | 2017-06-08 15:30:36 -0700 | |
---|---|---|
committer | 2017-06-09 11:14:49 -0700 | |
commit | 8bdda5a106b256865ce39f4a843452f45ad97599 (patch) | |
tree | a9b148609ab1be9067b69a39e9862e1d7a8d68c3 | |
parent | 58794c5c23f46a7476a58e5a10dbeebb6321aa90 (diff) |
ART: Update stl_util.h
Replace MakeUnique with std::make_unique. Remove unused functions.
Test: m
Change-Id: I3afdc0529cd6fb9d1797e5294a3d5ea2f6b38fc7
-rw-r--r-- | compiler/elf_writer_quick.cc | 20 | ||||
-rw-r--r-- | compiler/image_test.h | 7 | ||||
-rw-r--r-- | compiler/linker/output_stream_test.cc | 5 | ||||
-rw-r--r-- | compiler/oat_test.cc | 4 | ||||
-rw-r--r-- | compiler/oat_writer.cc | 4 | ||||
-rw-r--r-- | dex2oat/dex2oat.cc | 10 | ||||
-rw-r--r-- | oatdump/oatdump.cc | 4 | ||||
-rw-r--r-- | runtime/base/stl_util.h | 35 | ||||
-rw-r--r-- | runtime/common_runtime_test.cc | 10 | ||||
-rw-r--r-- | runtime/common_runtime_test.h | 8 |
10 files changed, 26 insertions, 81 deletions
diff --git a/compiler/elf_writer_quick.cc b/compiler/elf_writer_quick.cc index 63b7cad894..5d6dd2e1d7 100644 --- a/compiler/elf_writer_quick.cc +++ b/compiler/elf_writer_quick.cc @@ -22,7 +22,6 @@ #include "base/casts.h" #include "base/logging.h" -#include "base/stl_util.h" #include "compiled_method.h" #include "debug/elf_debug_writer.h" #include "debug/method_debug_info.h" @@ -137,15 +136,15 @@ std::unique_ptr<ElfWriter> CreateElfWriterQuick(InstructionSet instruction_set, const CompilerOptions* compiler_options, File* elf_file) { if (Is64BitInstructionSet(instruction_set)) { - return MakeUnique<ElfWriterQuick<ElfTypes64>>(instruction_set, - features, - compiler_options, - elf_file); + return std::make_unique<ElfWriterQuick<ElfTypes64>>(instruction_set, + features, + compiler_options, + elf_file); } else { - return MakeUnique<ElfWriterQuick<ElfTypes32>>(instruction_set, - features, - compiler_options, - elf_file); + return std::make_unique<ElfWriterQuick<ElfTypes32>>(instruction_set, + features, + compiler_options, + elf_file); } } @@ -161,7 +160,8 @@ ElfWriterQuick<ElfTypes>::ElfWriterQuick(InstructionSet instruction_set, rodata_size_(0u), text_size_(0u), bss_size_(0u), - output_stream_(MakeUnique<BufferedOutputStream>(MakeUnique<FileOutputStream>(elf_file))), + output_stream_( + std::make_unique<BufferedOutputStream>(std::make_unique<FileOutputStream>(elf_file))), builder_(new ElfBuilder<ElfTypes>(instruction_set, features, output_stream_.get())) {} template <typename ElfTypes> diff --git a/compiler/image_test.h b/compiler/image_test.h index 026e9e15bf..3d89757d51 100644 --- a/compiler/image_test.h +++ b/compiler/image_test.h @@ -26,7 +26,6 @@ #include "android-base/stringprintf.h" #include "art_method-inl.h" -#include "base/stl_util.h" #include "base/unix_file/fd_file.h" #include "class_linker-inl.h" #include "compiler_callbacks.h" @@ -291,9 +290,9 @@ inline void CompilationHelper::Compile(CompilerDriver* driver, if (kIsVdexEnabled) { for (size_t i = 0, size = vdex_files.size(); i != size; ++i) { - std::unique_ptr<BufferedOutputStream> vdex_out( - MakeUnique<BufferedOutputStream>( - MakeUnique<FileOutputStream>(vdex_files[i].GetFile()))); + std::unique_ptr<BufferedOutputStream> vdex_out = + std::make_unique<BufferedOutputStream>( + std::make_unique<FileOutputStream>(vdex_files[i].GetFile())); oat_writers[i]->WriteVerifierDeps(vdex_out.get(), nullptr); oat_writers[i]->WriteChecksumsAndVdexHeader(vdex_out.get()); } diff --git a/compiler/linker/output_stream_test.cc b/compiler/linker/output_stream_test.cc index 84c76f2c6c..09fef29d48 100644 --- a/compiler/linker/output_stream_test.cc +++ b/compiler/linker/output_stream_test.cc @@ -19,7 +19,6 @@ #include "base/unix_file/fd_file.h" #include "base/logging.h" -#include "base/stl_util.h" #include "buffered_output_stream.h" #include "common_runtime_test.h" @@ -79,7 +78,7 @@ TEST_F(OutputStreamTest, File) { TEST_F(OutputStreamTest, Buffered) { ScratchFile tmp; { - BufferedOutputStream buffered_output_stream(MakeUnique<FileOutputStream>(tmp.GetFile())); + BufferedOutputStream buffered_output_stream(std::make_unique<FileOutputStream>(tmp.GetFile())); SetOutputStream(buffered_output_stream); GenerateTestOutput(); } @@ -125,7 +124,7 @@ TEST_F(OutputStreamTest, BufferedFlush) { bool flush_called; }; - std::unique_ptr<CheckingOutputStream> cos = MakeUnique<CheckingOutputStream>(); + std::unique_ptr<CheckingOutputStream> cos = std::make_unique<CheckingOutputStream>(); CheckingOutputStream* checking_output_stream = cos.get(); BufferedOutputStream buffered(std::move(cos)); ASSERT_FALSE(checking_output_stream->flush_called); diff --git a/compiler/oat_test.cc b/compiler/oat_test.cc index 84ec8b3ee1..55d0bd95d7 100644 --- a/compiler/oat_test.cc +++ b/compiler/oat_test.cc @@ -225,8 +225,8 @@ class OatTest : public CommonCompilerTest { oat_writer.GetBssRootsOffset()); if (kIsVdexEnabled) { - std::unique_ptr<BufferedOutputStream> vdex_out( - MakeUnique<BufferedOutputStream>(MakeUnique<FileOutputStream>(vdex_file))); + std::unique_ptr<BufferedOutputStream> vdex_out = + std::make_unique<BufferedOutputStream>(std::make_unique<FileOutputStream>(vdex_file)); if (!oat_writer.WriteVerifierDeps(vdex_out.get(), nullptr)) { return false; } diff --git a/compiler/oat_writer.cc b/compiler/oat_writer.cc index 581b1ee593..59daf5a09e 100644 --- a/compiler/oat_writer.cc +++ b/compiler/oat_writer.cc @@ -515,8 +515,8 @@ bool OatWriter::WriteAndOpenDexFiles( ChecksumUpdatingOutputStream checksum_updating_rodata(oat_rodata, oat_header_.get()); if (kIsVdexEnabled) { - std::unique_ptr<BufferedOutputStream> vdex_out( - MakeUnique<BufferedOutputStream>(MakeUnique<FileOutputStream>(vdex_file))); + std::unique_ptr<BufferedOutputStream> vdex_out = + std::make_unique<BufferedOutputStream>(std::make_unique<FileOutputStream>(vdex_file)); // Write DEX files into VDEX, mmap and open them. if (!WriteDexFiles(vdex_out.get(), vdex_file, update_input_vdex) || !OpenDexFiles(vdex_file, verify, &dex_files_map, &dex_files)) { diff --git a/dex2oat/dex2oat.cc b/dex2oat/dex2oat.cc index 21e07246ce..3dd07031d5 100644 --- a/dex2oat/dex2oat.cc +++ b/dex2oat/dex2oat.cc @@ -1402,8 +1402,8 @@ class Dex2Oat FINAL { // Note: we're only invalidating the magic data in the file, as dex2oat needs the rest of // the information to remain valid. if (update_input_vdex_) { - std::unique_ptr<BufferedOutputStream> vdex_out(MakeUnique<BufferedOutputStream>( - MakeUnique<FileOutputStream>(vdex_files_.back().get()))); + std::unique_ptr<BufferedOutputStream> vdex_out = std::make_unique<BufferedOutputStream>( + std::make_unique<FileOutputStream>(vdex_files_.back().get())); if (!vdex_out->WriteFully(&VdexFile::Header::kVdexInvalidMagic, arraysize(VdexFile::Header::kVdexInvalidMagic))) { PLOG(ERROR) << "Failed to invalidate vdex header. File: " << vdex_out->GetLocation(); @@ -1900,8 +1900,8 @@ class Dex2Oat FINAL { verifier::VerifierDeps* verifier_deps = callbacks_->GetVerifierDeps(); for (size_t i = 0, size = oat_files_.size(); i != size; ++i) { File* vdex_file = vdex_files_[i].get(); - std::unique_ptr<BufferedOutputStream> vdex_out( - MakeUnique<BufferedOutputStream>(MakeUnique<FileOutputStream>(vdex_file))); + std::unique_ptr<BufferedOutputStream> vdex_out = + std::make_unique<BufferedOutputStream>(std::make_unique<FileOutputStream>(vdex_file)); if (!oat_writers_[i]->WriteVerifierDeps(vdex_out.get(), verifier_deps)) { LOG(ERROR) << "Failed to write verifier dependencies into VDEX " << vdex_file->GetPath(); @@ -2933,7 +2933,7 @@ static dex2oat::ReturnCode Dex2oat(int argc, char** argv) { // might produce a stack frame too large for this function or for // functions inlining it (such as main), that would not fit the // requirements of the `-Wframe-larger-than` option. - std::unique_ptr<Dex2Oat> dex2oat = MakeUnique<Dex2Oat>(&timings); + std::unique_ptr<Dex2Oat> dex2oat = std::make_unique<Dex2Oat>(&timings); // Parse arguments. Argument mistakes will lead to exit(EXIT_FAILURE) in UsageError. dex2oat->ParseArgs(argc, argv); diff --git a/oatdump/oatdump.cc b/oatdump/oatdump.cc index 0c64b9f9db..9b95de2fb0 100644 --- a/oatdump/oatdump.cc +++ b/oatdump/oatdump.cc @@ -130,8 +130,8 @@ class OatSymbolizer FINAL { if (elf_file == nullptr) { return false; } - std::unique_ptr<BufferedOutputStream> output_stream( - MakeUnique<BufferedOutputStream>(MakeUnique<FileOutputStream>(elf_file.get()))); + std::unique_ptr<BufferedOutputStream> output_stream = + std::make_unique<BufferedOutputStream>(std::make_unique<FileOutputStream>(elf_file.get())); builder_.reset(new ElfBuilder<ElfTypes>(isa, features.get(), output_stream.get())); builder_->Start(); diff --git a/runtime/base/stl_util.h b/runtime/base/stl_util.h index f99465ab66..b27297241d 100644 --- a/runtime/base/stl_util.h +++ b/runtime/base/stl_util.h @@ -25,13 +25,6 @@ namespace art { -// Sort and remove duplicates of an STL vector or deque. -template<class T> -void STLSortAndRemoveDuplicates(T* v) { - std::sort(v->begin(), v->end()); - v->erase(std::unique(v->begin(), v->end()), v->end()); -} - // STLDeleteContainerPointers() // For a range within a container of pointers, calls delete // (non-array version) on these pointers. @@ -83,20 +76,6 @@ void STLDeleteValues(T *v) { } } -template <class T> -std::string ToString(const T& v) { - std::ostringstream os; - os << "["; - for (size_t i = 0; i < v.size(); ++i) { - os << v[i]; - if (i < v.size() - 1) { - os << ", "; - } - } - os << "]"; - return os.str(); -} - // Deleter using free() for use with std::unique_ptr<>. See also UniqueCPtr<> below. struct FreeDelete { // NOTE: Deleting a const object is valid but free() takes a non-const pointer. @@ -109,13 +88,6 @@ struct FreeDelete { template <typename T> using UniqueCPtr = std::unique_ptr<T, FreeDelete>; -// C++14 from-the-future import (std::make_unique) -// Invoke the constructor of 'T' with the provided args, and wrap the result in a unique ptr. -template <typename T, typename ... Args> -std::unique_ptr<T> MakeUnique(Args&& ... args) { - return std::unique_ptr<T>(new T(std::forward<Args>(args)...)); -} - // Find index of the first element with the specified value known to be in the container. template <typename Container, typename T> size_t IndexOfElement(const Container& container, const T& value) { @@ -150,13 +122,6 @@ bool ContainsElement(const Container& container, const T& value, size_t start_po return it != container.end(); } -// const char* compare function suitable for std::map or std::set. -struct CStringLess { - bool operator()(const char* lhs, const char* rhs) const { - return strcmp(lhs, rhs) < 0; - } -}; - // 32-bit FNV-1a hash function suitable for std::unordered_map. // It can be used with any container which works with range-based for loop. // See http://en.wikipedia.org/wiki/Fowler%E2%80%93Noll%E2%80%93Vo_hash_function diff --git a/runtime/common_runtime_test.cc b/runtime/common_runtime_test.cc index 01c6641ae9..f9259944b4 100644 --- a/runtime/common_runtime_test.cc +++ b/runtime/common_runtime_test.cc @@ -728,13 +728,3 @@ void CheckJniAbortCatcher::Hook(void* data, const std::string& reason) { } } // namespace art - -namespace std { - -template <typename T> -std::ostream& operator<<(std::ostream& os, const std::vector<T>& rhs) { -os << ::art::ToString(rhs); -return os; -} - -} // namespace std diff --git a/runtime/common_runtime_test.h b/runtime/common_runtime_test.h index 24dbd058ec..1274a3623b 100644 --- a/runtime/common_runtime_test.h +++ b/runtime/common_runtime_test.h @@ -258,12 +258,4 @@ class CheckJniAbortCatcher { } // namespace art -namespace std { - -// TODO: isn't gtest supposed to be able to print STL types for itself? -template <typename T> -std::ostream& operator<<(std::ostream& os, const std::vector<T>& rhs); - -} // namespace std - #endif // ART_RUNTIME_COMMON_RUNTIME_TEST_H_ |