aboutsummaryrefslogtreecommitdiffstats
path: root/src/resp.hpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/resp.hpp')
-rw-r--r--src/resp.hpp22
1 files changed, 7 insertions, 15 deletions
diff --git a/src/resp.hpp b/src/resp.hpp
index 3c949a0..acf7725 100644
--- a/src/resp.hpp
+++ b/src/resp.hpp
@@ -205,9 +205,9 @@ struct ATuple : public AST {
ATuple(const AST* fst, const ATuple* rst, Cursor c=Cursor())
: AST(T_TUPLE, c), _fst(fst), _rst(rst) {}
- const AST* head() const { return _fst; }
- const AST* last() const { return _rst; }
- bool empty() const { return _fst == 0 && _rst ==0; }
+ const AST* fst() const { return _fst; }
+ const ATuple* rst() const { return _rst; }
+ bool empty() const { return _fst == 0 && _rst ==0; }
size_t list_len() const {
size_t ret = 0;
@@ -232,22 +232,14 @@ struct ATuple : public AST {
void last(ATuple* ast) { _rst = ast; }
struct const_iterator {
- explicit const_iterator(const ATuple* n) : node(n) {}
- inline void increment() {
- if (node->last())
- node = node->last()->as_tuple();
- else
- node = NULL;
- }
+ explicit inline const_iterator(const ATuple* n) : node(n) {}
inline const_iterator& operator++() {
- assert(node);
- increment();
+ node = node->rst();
return *this;
}
inline const_iterator operator++(int) {
- assert(node);
const const_iterator ret(node);
- increment();
+ node = node->rst();
return ret;
}
inline bool operator==(const const_iterator& i) const {
@@ -256,7 +248,7 @@ struct ATuple : public AST {
inline bool operator!=(const const_iterator& i) const {
return !operator==(i);
}
- const AST* operator*() { return node->head(); }
+ inline const AST* operator*() { return node->fst(); }
const ATuple* node;
};