From dbed3fea6f4c9c927383a7697952936d3c5305c7 Mon Sep 17 00:00:00 2001 From: Peter Johnson Date: Sun, 21 Jun 2015 22:07:29 -0700 Subject: [PATCH] Move remaining read functions. Change-Id: I415edc98fa06bb8e2c1a950ebdeb42775d915a77 --- src/nt_encoding.h | 28 ---------------------------- src/nt_wiredecoder.h | 13 +++++++++---- 2 files changed, 9 insertions(+), 32 deletions(-) diff --git a/src/nt_encoding.h b/src/nt_encoding.h index f2c8c30fc8..ff40f40090 100644 --- a/src/nt_encoding.h +++ b/src/nt_encoding.h @@ -34,34 +34,6 @@ Write32(char* &buf, unsigned long val) void WriteDouble(char* &buf, double val); -inline unsigned int -Read8(char* &buf) -{ - unsigned int val = (*((unsigned char *)buf)) & 0xff; - ++buf; - return val; -} - -inline unsigned int -Read16(char* &buf) -{ - unsigned int val = (*((unsigned char *)buf)) & 0xff; - ++buf; val <<= 8; val |= (*((unsigned char *)buf)) & 0xff; - ++buf; - return val; -} - -inline unsigned long -Read32(char* &buf) -{ - unsigned int val = (*((unsigned char *)buf)) & 0xff; - ++buf; val <<= 8; val |= (*((unsigned char *)buf)) & 0xff; - ++buf; val <<= 8; val |= (*((unsigned char *)buf)) & 0xff; - ++buf; val <<= 8; val |= (*((unsigned char *)buf)) & 0xff; - ++buf; - return val; -} - } // namespace NtImpl #endif /* NT_UTIL_H */ diff --git a/src/nt_wiredecoder.h b/src/nt_wiredecoder.h index 15e75b77b2..d5b0012030 100644 --- a/src/nt_wiredecoder.h +++ b/src/nt_wiredecoder.h @@ -13,7 +13,6 @@ #include "ntcore.h" #include "nt_leb128.h" #include "nt_raw_istream.h" -#include "nt_encoding.h" namespace NtImpl { @@ -50,7 +49,7 @@ public: { char *buf; if (!Read(&buf, 1)) return false; - *val = NtImpl::Read8(buf); + *val = (*((unsigned char *)buf)) & 0xff; return true; } @@ -58,7 +57,9 @@ public: { char *buf; if (!Read(&buf, 2)) return false; - *val = NtImpl::Read16(buf); + unsigned int v = (*((unsigned char *)buf)) & 0xff; + ++buf; v <<= 8; v |= (*((unsigned char *)buf)) & 0xff; + *val = v; return true; } @@ -66,7 +67,11 @@ public: { char *buf; if (!Read(&buf, 4)) return false; - *val = NtImpl::Read32(buf); + unsigned int v = (*((unsigned char *)buf)) & 0xff; + ++buf; v <<= 8; v |= (*((unsigned char *)buf)) & 0xff; + ++buf; v <<= 8; v |= (*((unsigned char *)buf)) & 0xff; + ++buf; v <<= 8; v |= (*((unsigned char *)buf)) & 0xff; + *val = v; return true; }