From d75ba1c3573d3d5146d0abe8cb376dca94be94d5 Mon Sep 17 00:00:00 2001 From: Ted Kremenek Date: Thu, 4 Dec 2008 22:51:11 +0000 Subject: Have raw_fd_ostream keep track of the position in the file to make tell() go faster by not requiring a flush(). git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@60560 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/llvm/Support/raw_ostream.h | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'include/llvm/Support') diff --git a/include/llvm/Support/raw_ostream.h b/include/llvm/Support/raw_ostream.h index 2b4b17d7b2..1a4f6bf6f4 100644 --- a/include/llvm/Support/raw_ostream.h +++ b/include/llvm/Support/raw_ostream.h @@ -151,6 +151,7 @@ private: class raw_fd_ostream : public raw_ostream { int FD; bool ShouldClose; + uint64_t pos; public: /// raw_fd_ostream - Open the specified file for writing. If an /// error occurs, information about the error is put into ErrorInfo, @@ -178,7 +179,9 @@ public: void close(); /// tell - Return the current offset with the file. - uint64_t tell(); + uint64_t tell() { + return pos + (OutBufCur - OutBufStart); + } }; /// raw_stdout_ostream - This is a stream that always prints to stdout. -- cgit v1.2.3