From: Pierre Ossman Date: Tue, 10 Nov 2015 16:13:27 +0000 (+0100) Subject: Add efficient method to copy data between two streams X-Git-Tag: v1.6.90~95^2~22 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=ded49076c84048003e4c94da2d53ed93b21740af;p=tigervnc.git Add efficient method to copy data between two streams --- diff --git a/common/rdr/OutStream.h b/common/rdr/OutStream.h index 94d57dd3..a749a208 100644 --- a/common/rdr/OutStream.h +++ b/common/rdr/OutStream.h @@ -25,6 +25,7 @@ #define __RDR_OUTSTREAM_H__ #include +#include #include // for memcpy namespace rdr { @@ -100,6 +101,17 @@ namespace rdr { } } + // copyBytes() efficiently transfers data between streams + + void copyBytes(InStream* is, int length) { + while (length > 0) { + int n = check(1, length); + is->readBytes(ptr, n); + ptr += n; + length -= n; + } + } + // writeOpaqueN() writes a quantity without byte-swapping. inline void writeOpaque8( U8 u) { writeU8(u); }