version 2.3.0_beta
optimize PIChunkStream::readAll() optimize PIEvaluator
This commit is contained in:
@@ -79,11 +79,11 @@ public:
|
||||
//! Returns stream version
|
||||
Version version() const {return (Version)version_;}
|
||||
|
||||
|
||||
|
||||
//! Read one chunk from stream and returns its ID
|
||||
int read();
|
||||
|
||||
//! Read all chunks from stream
|
||||
//! Read all chunks from stream. This function just index input data
|
||||
void readAll();
|
||||
|
||||
//! Returns last readed chunk ID
|
||||
@@ -100,7 +100,9 @@ public:
|
||||
//! Place value of chunk with id \"id\" into \"v\". You should call \a readAll() before using this function!
|
||||
template <typename T>
|
||||
const PIChunkStream & get(int id, T & v) const {
|
||||
PIByteArray ba = data_map.value(id);
|
||||
PIPair<int, int> pos = data_map.value(id);
|
||||
if (pos.first < 0 || pos.second == 0) return *this;
|
||||
PIByteArray ba(data_->data(pos.first), pos.second);
|
||||
if (!ba.isEmpty())
|
||||
ba >> v;
|
||||
return *this;
|
||||
@@ -109,13 +111,14 @@ public:
|
||||
private:
|
||||
void _init();
|
||||
|
||||
static uint readVInt(PIByteArray & s);
|
||||
static uint readVInt(PIByteArray & s, uchar * bytes = 0);
|
||||
static void writeVInt(PIByteArray & s, uint val);
|
||||
static int peekVInt(Version version_, PIByteArray * data_, int pos, PIByteArray & hdr, uint & ret);
|
||||
|
||||
int last_id;
|
||||
uchar version_;
|
||||
PIByteArray * data_, last_data, tmp_data;
|
||||
PIMap<int, PIByteArray> data_map;
|
||||
PIMap<int, PIPair<int, int>> data_map;
|
||||
|
||||
template <typename T> friend PIChunkStream & operator <<(PIChunkStream & s, const PIChunkStream::Chunk<T> & c);
|
||||
template <typename T> friend PIChunkStream & operator <<(PIChunkStream & s, const PIChunkStream::ChunkConst<T> & c);
|
||||
|
||||
Reference in New Issue
Block a user