aboutsummaryrefslogtreecommitdiffstats
path: root/lib/Support
diff options
context:
space:
mode:
authorTed Kremenek <kremenek@apple.com>2008-12-04 22:51:11 +0000
committerTed Kremenek <kremenek@apple.com>2008-12-04 22:51:11 +0000
commite6d26895fcc91e461c16fdce0b4641e132a4b768 (patch)
treed2f045344a0b9494765f500cedc90e8d779c13ee /lib/Support
parent6eadeb1329683bf7554e5aef6ca4d942bcb7750b (diff)
downloadexternal_llvm-e6d26895fcc91e461c16fdce0b4641e132a4b768.zip
external_llvm-e6d26895fcc91e461c16fdce0b4641e132a4b768.tar.gz
external_llvm-e6d26895fcc91e461c16fdce0b4641e132a4b768.tar.bz2
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
Diffstat (limited to 'lib/Support')
-rw-r--r--lib/Support/raw_ostream.cpp14
1 files changed, 4 insertions, 10 deletions
diff --git a/lib/Support/raw_ostream.cpp b/lib/Support/raw_ostream.cpp
index b10677e..96c9a3a 100644
--- a/lib/Support/raw_ostream.cpp
+++ b/lib/Support/raw_ostream.cpp
@@ -202,7 +202,7 @@ void format_object_base::home() {
/// stream should be immediately destroyed; the string will be empty
/// if no error occurred.
raw_fd_ostream::raw_fd_ostream(const char *Filename, bool Binary,
- std::string &ErrorInfo) {
+ std::string &ErrorInfo) : pos(0) {
ErrorInfo.clear();
// Handle "-" as stdout.
@@ -240,8 +240,10 @@ raw_fd_ostream::~raw_fd_ostream() {
void raw_fd_ostream::flush_impl() {
assert (FD >= 0 && "File already closed.");
- if (OutBufCur-OutBufStart)
+ if (OutBufCur-OutBufStart) {
+ pos += (OutBufCur - OutBufStart);
::write(FD, OutBufStart, OutBufCur-OutBufStart);
+ }
HandleFlush();
}
@@ -253,14 +255,6 @@ void raw_fd_ostream::close() {
FD = -1;
}
-uint64_t raw_fd_ostream::tell() {
- // We have to take into account the bytes waiting in the buffer. For now
- // we do the easy thing and just flush the buffer before getting the
- // current file offset.
- flush();
- return (uint64_t) lseek(FD, 0, SEEK_CUR);
-}
-
//===----------------------------------------------------------------------===//
// raw_stdout/err_ostream
//===----------------------------------------------------------------------===//