Browse Source

Add efficient method to copy data between two streams

tags/v1.6.90
Pierre Ossman 8 years ago
parent
commit
ded49076c8
1 changed files with 12 additions and 0 deletions
  1. 12
    0
      common/rdr/OutStream.h

+ 12
- 0
common/rdr/OutStream.h View File

@@ -25,6 +25,7 @@
#define __RDR_OUTSTREAM_H__

#include <rdr/types.h>
#include <rdr/InStream.h>
#include <string.h> // 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); }

Loading…
Cancel
Save