diff options
author | Chris Lattner <sabre@nondot.org> | 2001-09-07 16:27:49 +0000 |
---|---|---|
committer | Chris Lattner <sabre@nondot.org> | 2001-09-07 16:27:49 +0000 |
commit | 368216420a222c6cd2fd45980e59119122ae280b (patch) | |
tree | 2545c326626969295bc1dedb60751f660a635ee6 /include/llvm/Bytecode/Primitives.h | |
parent | 740611a0347b9d9658c86c252bd7448cde70f1bc (diff) |
Use a deque instead of a vector for greater efficiency writing bytecode
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@434 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'include/llvm/Bytecode/Primitives.h')
-rw-r--r-- | include/llvm/Bytecode/Primitives.h | 20 |
1 files changed, 10 insertions, 10 deletions
diff --git a/include/llvm/Bytecode/Primitives.h b/include/llvm/Bytecode/Primitives.h index d687fb8185..178904d15f 100644 --- a/include/llvm/Bytecode/Primitives.h +++ b/include/llvm/Bytecode/Primitives.h @@ -14,7 +14,7 @@ #include "llvm/Support/DataTypes.h" #include <string> -#include <vector> +#include <deque> //===----------------------------------------------------------------------===// // Reading Primitives @@ -157,7 +157,7 @@ static inline bool input_data(const unsigned char *&Buf, // string... note that this should be inlined always so only the relevant IF // body should be included... // -static inline void output(unsigned i, vector<unsigned char> &Out, int pos = -1){ +static inline void output(unsigned i, deque<unsigned char> &Out, int pos = -1){ #ifdef LITTLE_ENDIAN if (pos == -1) Out.insert(Out.end(), (unsigned char*)&i, (unsigned char*)&i+4); @@ -178,7 +178,7 @@ static inline void output(unsigned i, vector<unsigned char> &Out, int pos = -1){ #endif } -static inline void output(int i, vector<unsigned char> &Out) { +static inline void output(int i, deque<unsigned char> &Out) { output((unsigned)i, Out); } @@ -191,7 +191,7 @@ static inline void output(int i, vector<unsigned char> &Out) { // // Note that using this may cause the output buffer to become unaligned... // -static inline void output_vbr(uint64_t i, vector<unsigned char> &out) { +static inline void output_vbr(uint64_t i, deque<unsigned char> &out) { while (1) { if (i < 0x80) { // done? out.push_back((unsigned char)i); // We know the high bit is clear... @@ -205,7 +205,7 @@ static inline void output_vbr(uint64_t i, vector<unsigned char> &out) { } } -static inline void output_vbr(unsigned i, vector<unsigned char> &out) { +static inline void output_vbr(unsigned i, deque<unsigned char> &out) { while (1) { if (i < 0x80) { // done? out.push_back((unsigned char)i); // We know the high bit is clear... @@ -219,7 +219,7 @@ static inline void output_vbr(unsigned i, vector<unsigned char> &out) { } } -static inline void output_vbr(int64_t i, vector<unsigned char> &out) { +static inline void output_vbr(int64_t i, deque<unsigned char> &out) { if (i < 0) output_vbr(((uint64_t)(-i) << 1) | 1, out); // Set low order sign bit... else @@ -227,7 +227,7 @@ static inline void output_vbr(int64_t i, vector<unsigned char> &out) { } -static inline void output_vbr(int i, vector<unsigned char> &out) { +static inline void output_vbr(int i, deque<unsigned char> &out) { if (i < 0) output_vbr(((unsigned)(-i) << 1) | 1, out); // Set low order sign bit... else @@ -237,12 +237,12 @@ static inline void output_vbr(int i, vector<unsigned char> &out) { // align32 - emit the minimal number of bytes that will bring us to 32 bit // alignment... // -static inline void align32(vector<unsigned char> &Out) { +static inline void align32(deque<unsigned char> &Out) { int NumPads = (4-(Out.size() & 3)) & 3; // Bytes to get padding to 32 bits while (NumPads--) Out.push_back((unsigned char)0xAB); } -static inline void output(const string &s, vector<unsigned char> &Out, +static inline void output(const string &s, deque<unsigned char> &Out, bool Aligned = true) { unsigned Len = s.length(); output_vbr(Len, Out); // Strings may have an arbitrary length... @@ -253,7 +253,7 @@ static inline void output(const string &s, vector<unsigned char> &Out, } static inline void output_data(void *Ptr, void *End, - vector<unsigned char> &Out, bool Align = false) { + deque<unsigned char> &Out, bool Align = false) { #ifdef LITTLE_ENDIAN Out.insert(Out.end(), (unsigned char*)Ptr, (unsigned char*)End); #else |