Use memcpy instead of iterating on buf_read/write
diff --git a/pb_decode.c b/pb_decode.c
index f388932..ce3a8b4 100644
--- a/pb_decode.c
+++ b/pb_decode.c
@@ -67,14 +67,12 @@
static bool checkreturn buf_read(pb_istream_t *stream, pb_byte_t *buf, size_t count)
{
- size_t i;
const pb_byte_t *source = (const pb_byte_t*)stream->state;
stream->state = (pb_byte_t*)stream->state + count;
if (buf != NULL)
{
- for (i = 0; i < count; i++)
- buf[i] = source[i];
+ memcpy(buf, source, count * sizeof(pb_byte_t));
}
return true;
diff --git a/pb_encode.c b/pb_encode.c
index 6fcbfa6..c30d3d7 100644
--- a/pb_encode.c
+++ b/pb_encode.c
@@ -51,12 +51,10 @@
static bool checkreturn buf_write(pb_ostream_t *stream, const pb_byte_t *buf, size_t count)
{
- size_t i;
pb_byte_t *dest = (pb_byte_t*)stream->state;
stream->state = dest + count;
- for (i = 0; i < count; i++)
- dest[i] = buf[i];
+ memcpy(dest, buf, count * sizeof(pb_byte_t));
return true;
}