summaryrefslogtreecommitdiff
path: root/core/fxcrt/cfx_memorystream.h
diff options
context:
space:
mode:
authorLei Zhang <thestig@chromium.org>2018-08-15 18:42:32 +0000
committerChromium commit bot <commit-bot@chromium.org>2018-08-15 18:42:32 +0000
commit48ae3075a5c80e75923a60d4d0ba0b56d9b08c2a (patch)
tree464540a6b17b7e2cc3096d7f579729745f5b0664 /core/fxcrt/cfx_memorystream.h
parent55ccb526913debb3269a33792bbd61b05656ec46 (diff)
downloadpdfium-chromium/3524.tar.xz
Make CFX_MemoryStream always consecutive.chromium/3524
Non-consecutive mode has questionable correctness and is not an obvious performance win. Change-Id: Idaa66e5ee5c4604628a0f55b67d5a04ab47ea5ec Reviewed-on: https://pdfium-review.googlesource.com/40050 Reviewed-by: Tom Sepez <tsepez@chromium.org> Commit-Queue: Lei Zhang <thestig@chromium.org>
Diffstat (limited to 'core/fxcrt/cfx_memorystream.h')
-rw-r--r--core/fxcrt/cfx_memorystream.h14
1 files changed, 5 insertions, 9 deletions
diff --git a/core/fxcrt/cfx_memorystream.h b/core/fxcrt/cfx_memorystream.h
index 95f62b6a2c..47e491275c 100644
--- a/core/fxcrt/cfx_memorystream.h
+++ b/core/fxcrt/cfx_memorystream.h
@@ -7,8 +7,9 @@
#ifndef CORE_FXCRT_CFX_MEMORYSTREAM_H_
#define CORE_FXCRT_CFX_MEMORYSTREAM_H_
-#include <vector>
+#include <memory>
+#include "core/fxcrt/fx_memory.h"
#include "core/fxcrt/fx_stream.h"
#include "core/fxcrt/retain_ptr.h"
@@ -26,24 +27,19 @@ class CFX_MemoryStream : public IFX_SeekableStream {
bool WriteBlock(const void* buffer, FX_FILESIZE offset, size_t size) override;
bool Flush() override;
- uint8_t* GetBuffer() {
- return !m_Blocks.empty() ? m_Blocks.front() : nullptr;
- }
+ const uint8_t* GetBuffer() const { return m_data.get(); }
private:
- explicit CFX_MemoryStream(bool bConsecutive);
+ CFX_MemoryStream();
// Takes ownership of |pBuffer|.
CFX_MemoryStream(uint8_t* pBuffer, size_t nSize);
~CFX_MemoryStream() override;
- bool ExpandBlocks(size_t size);
-
- std::vector<uint8_t*> m_Blocks;
+ std::unique_ptr<uint8_t, FxFreeDeleter> m_data;
size_t m_nTotalSize;
size_t m_nCurSize;
size_t m_nCurPos = 0;
- const bool m_bConsecutive;
};
#endif // CORE_FXCRT_CFX_MEMORYSTREAM_H_