Reduced memory consumption by not duplicating spaces and comments

This commit is contained in:
Benoit Blanchon
2016-12-29 17:26:16 +01:00
parent 8032a4b564
commit 3f96e070ce
20 changed files with 596 additions and 287 deletions

View File

@@ -13,24 +13,29 @@ namespace Internals {
// Parse JSON string to create JsonArrays and JsonObjects
// This internal class is not indended to be used directly.
// Instead, use JsonBuffer.parseArray() or .parseObject()
template <typename TIterator>
class StringReader {
TIterator _input;
char _current, _next;
public:
StringReader(const char *input) : _ptr(input ? input : "") {}
void skip() {
_ptr++;
StringReader(const TIterator& input) : _input(input) {
_current = _input.next();
_next = _input.next();
}
char peek() const {
return _ptr[0];
void move() {
_current = _next;
_next = _input.next();
}
char peekNext() const {
return _ptr[1];
char current() const {
return _current;
}
private:
const char *_ptr;
char next() const {
return _next;
}
};
}
}