File tree Expand file tree Collapse file tree 1 file changed +9
-5
lines changed Expand file tree Collapse file tree 1 file changed +9
-5
lines changed Original file line number Diff line number Diff line change @@ -45,18 +45,22 @@ class cbuf {
45
45
return _begin - _end - 1 ;
46
46
}
47
47
48
- bool empty () const {
48
+ inline bool empty () const {
49
49
return _begin == _end;
50
50
}
51
51
52
+ inline bool full () const {
53
+ return wrap_if_bufend (_end + 1 ) == _begin;
54
+ }
55
+
52
56
int peek () {
53
- if (_end == _begin ) return -1 ;
57
+ if (empty () ) return -1 ;
54
58
55
59
return static_cast <int >(*_begin);
56
60
}
57
61
58
62
int read () {
59
- if (getSize () == 0 ) return -1 ;
63
+ if (empty () ) return -1 ;
60
64
61
65
char result = *_begin;
62
66
_begin = wrap_if_bufend (_begin + 1 );
@@ -80,7 +84,7 @@ class cbuf {
80
84
}
81
85
82
86
size_t write (char c) {
83
- if (room () == 0 ) return 0 ;
87
+ if (full () ) return 0 ;
84
88
85
89
*_end = c;
86
90
_end = wrap_if_bufend (_end + 1 );
@@ -109,7 +113,7 @@ class cbuf {
109
113
}
110
114
111
115
private:
112
- inline char * wrap_if_bufend (char * ptr) {
116
+ inline char * wrap_if_bufend (char * ptr) const {
113
117
return (ptr == _bufend) ? _buf : ptr;
114
118
}
115
119
You can’t perform that action at this time.
0 commit comments