diff options
author | Max Horn | 2010-11-18 20:27:15 +0000 |
---|---|---|
committer | Max Horn | 2010-11-18 20:27:15 +0000 |
commit | 9fb1e2b17ea294b06297139198cd80c06783a714 (patch) | |
tree | 73ee6bee476d6b470caa53390d70591b6c55ee20 /common | |
parent | 9531b7766ca99e1c6aac78474a4c73188dbad00f (diff) | |
download | scummvm-rg350-9fb1e2b17ea294b06297139198cd80c06783a714.tar.gz scummvm-rg350-9fb1e2b17ea294b06297139198cd80c06783a714.tar.bz2 scummvm-rg350-9fb1e2b17ea294b06297139198cd80c06783a714.zip |
COMMON: Change wrapBufferedWriteStream() to always disposes wrapped stream
This is the only we need right now, and it saves a few bytes per
instance. The template approach I used before has the drawback that it
increases the binary size, which negates the benefit. Thanks to LordHoto
for pointing this out.
svn-id: r54344
Diffstat (limited to 'common')
-rw-r--r-- | common/stream.cpp | 16 | ||||
-rw-r--r-- | common/stream.h | 6 |
2 files changed, 7 insertions, 15 deletions
diff --git a/common/stream.cpp b/common/stream.cpp index b82a70409a..2abd6fc986 100644 --- a/common/stream.cpp +++ b/common/stream.cpp @@ -421,7 +421,6 @@ namespace { /** * Wrapper class which adds buffering to any WriteStream. */ -template <DisposeAfterUse::Flag _disposeParentStream> class BufferedWriteStream : public WriteStream { protected: WriteStream *_parentStream; @@ -462,8 +461,7 @@ public: const bool flushResult = flushBuffer(); assert(flushResult); - if (_disposeParentStream) - delete _parentStream; + delete _parentStream; delete[] _buf; } @@ -492,15 +490,9 @@ public: } // End of nameless namespace -WriteStream *wrapBufferedWriteStream(WriteStream *parentStream, uint32 bufSize, DisposeAfterUse::Flag disposeParentStream) { - if (parentStream) { - switch (disposeParentStream) { - case DisposeAfterUse::YES: - return new BufferedWriteStream<DisposeAfterUse::YES>(parentStream, bufSize); - case DisposeAfterUse::NO: - return new BufferedWriteStream<DisposeAfterUse::NO>(parentStream, bufSize); - } - } +WriteStream *wrapBufferedWriteStream(WriteStream *parentStream, uint32 bufSize) { + if (parentStream) + return new BufferedWriteStream(parentStream, bufSize); return 0; } diff --git a/common/stream.h b/common/stream.h index 14b1243ca0..9674375dd2 100644 --- a/common/stream.h +++ b/common/stream.h @@ -508,13 +508,13 @@ SeekableReadStream *wrapBufferedSeekableReadStream(SeekableReadStream *parentStr /** * Take an arbitrary WriteStream and wrap it in a custom stream which * transparently provides buffering. - * Users can specify how big the buffer should be, and whether the wrapped - * stream should be disposed when the wrapper is disposed. + * Users can specify how big the buffer should be. Currently, the + * parent stream is \em always disposed when the wrapper is disposed. * * It is safe to call this with a NULL parameter (in this case, NULL is * returned). */ -WriteStream *wrapBufferedWriteStream(WriteStream *parentStream, uint32 bufSize, DisposeAfterUse::Flag disposeParentStream); +WriteStream *wrapBufferedWriteStream(WriteStream *parentStream, uint32 bufSize); /** * Simple memory based 'stream', which implements the ReadStream interface for |