From 854ea3c580f698e0bcfd3caad0a54bd139430805 Mon Sep 17 00:00:00 2001 From: Dan Gohman Date: Thu, 13 Aug 2009 17:41:40 +0000 Subject: [PATCH] Set raw_os_ostream, raw_string_ostream, and raw_svector_ostream to be unbuffered. std::ostream does its own buffering, and std::string and SmallVector both have allocation strategies intended to handle frequent appending. llvm-svn: 78924 --- llvm/include/llvm/Support/raw_ostream.h | 10 ++++------ llvm/lib/Support/raw_ostream.cpp | 12 ------------ 2 files changed, 4 insertions(+), 18 deletions(-) diff --git a/llvm/include/llvm/Support/raw_ostream.h b/llvm/include/llvm/Support/raw_ostream.h index b1b96f231695..d9110dd31d8a 100644 --- a/llvm/include/llvm/Support/raw_ostream.h +++ b/llvm/include/llvm/Support/raw_ostream.h @@ -376,8 +376,7 @@ class raw_os_ostream : public raw_ostream { virtual uint64_t current_pos(); public: - raw_os_ostream(std::ostream &O) : OS(O) {} - ~raw_os_ostream(); + raw_os_ostream(std::ostream &O) : raw_ostream(true), OS(O) {} /// tell - Return the current offset with the stream. uint64_t tell(); @@ -395,8 +394,7 @@ class raw_string_ostream : public raw_ostream { /// counting the bytes currently in the buffer. virtual uint64_t current_pos() { return OS.size(); } public: - explicit raw_string_ostream(std::string &O) : OS(O) {} - ~raw_string_ostream(); + explicit raw_string_ostream(std::string &O) : raw_ostream(true), OS(O) {} /// tell - Return the current offset with the stream. uint64_t tell() { return OS.size() + GetNumBytesInBuffer(); } @@ -422,8 +420,8 @@ class raw_svector_ostream : public raw_ostream { /// counting the bytes currently in the buffer. virtual uint64_t current_pos(); public: - explicit raw_svector_ostream(SmallVectorImpl &O) : OS(O) {} - ~raw_svector_ostream(); + explicit raw_svector_ostream(SmallVectorImpl &O) + : raw_ostream(true), OS(O) {} /// tell - Return the current offset with the stream. uint64_t tell(); diff --git a/llvm/lib/Support/raw_ostream.cpp b/llvm/lib/Support/raw_ostream.cpp index c6d609bfc742..5eaf7bf6a04e 100644 --- a/llvm/lib/Support/raw_ostream.cpp +++ b/llvm/lib/Support/raw_ostream.cpp @@ -441,10 +441,6 @@ raw_ostream &llvm::nulls() { // raw_os_ostream //===----------------------------------------------------------------------===// -raw_os_ostream::~raw_os_ostream() { - flush(); -} - void raw_os_ostream::write_impl(const char *Ptr, size_t Size) { OS.write(Ptr, Size); } @@ -459,10 +455,6 @@ uint64_t raw_os_ostream::tell() { // raw_string_ostream //===----------------------------------------------------------------------===// -raw_string_ostream::~raw_string_ostream() { - flush(); -} - void raw_string_ostream::write_impl(const char *Ptr, size_t Size) { OS.append(Ptr, Size); } @@ -471,10 +463,6 @@ void raw_string_ostream::write_impl(const char *Ptr, size_t Size) { // raw_svector_ostream //===----------------------------------------------------------------------===// -raw_svector_ostream::~raw_svector_ostream() { - flush(); -} - void raw_svector_ostream::write_impl(const char *Ptr, size_t Size) { OS.append(Ptr, Ptr + Size); }