aboutsummaryrefslogtreecommitdiff
path: root/CPP/7zip/Common/OutBuffer.h
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--CPP/7zip/Common/OutBuffer.h29
1 files changed, 27 insertions, 2 deletions
diff --git a/CPP/7zip/Common/OutBuffer.h b/CPP/7zip/Common/OutBuffer.h
index 88f5787..af78c4f 100644
--- a/CPP/7zip/Common/OutBuffer.h
+++ b/CPP/7zip/Common/OutBuffer.h
@@ -45,6 +45,7 @@ public:
45 HRESULT Flush() throw(); 45 HRESULT Flush() throw();
46 void FlushWithCheck(); 46 void FlushWithCheck();
47 47
48 Z7_FORCE_INLINE
48 void WriteByte(Byte b) 49 void WriteByte(Byte b)
49 { 50 {
50 UInt32 pos = _pos; 51 UInt32 pos = _pos;
@@ -54,10 +55,34 @@ public:
54 if (pos == _limitPos) 55 if (pos == _limitPos)
55 FlushWithCheck(); 56 FlushWithCheck();
56 } 57 }
58
57 void WriteBytes(const void *data, size_t size) 59 void WriteBytes(const void *data, size_t size)
58 { 60 {
59 for (size_t i = 0; i < size; i++) 61 while (size)
60 WriteByte(((const Byte *)data)[i]); 62 {
63 UInt32 pos = _pos;
64 size_t cur = (size_t)(_limitPos - pos);
65 if (cur >= size)
66 cur = size;
67 size -= cur;
68 Byte *dest = _buf + pos;
69 pos += (UInt32)cur;
70 _pos = pos;
71#if 0
72 memcpy(dest, data, cur);
73 data = (const void *)((const Byte *)data + cur);
74#else
75 const Byte * const lim = (const Byte *)data + cur;
76 do
77 {
78 *dest++ = *(const Byte *)data;
79 data = (const void *)((const Byte *)data + 1);
80 }
81 while (data != lim);
82#endif
83 if (pos == _limitPos)
84 FlushWithCheck();
85 }
61 } 86 }
62 87
63 Byte *GetOutBuffer(size_t &avail) 88 Byte *GetOutBuffer(size_t &avail)