Inverted control flow, engine as library
This commit is contained in:
@@ -111,6 +111,19 @@ void StreamBuffer::clear() {
|
||||
lua_reader_size_ = 0;
|
||||
}
|
||||
|
||||
std::string StreamBuffer::readline() {
|
||||
char *p = read_cursor_;
|
||||
while ((p < write_cursor_) && (*p != '\n')) p++;
|
||||
if (p == write_cursor_) {
|
||||
return "";
|
||||
} else {
|
||||
p++;
|
||||
std::string result(read_cursor_, p - read_cursor_);
|
||||
read_cursor_ = p;
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
||||
// These routines return true if you can losslessly cast the
|
||||
// specified value to the specified type.
|
||||
|
||||
|
||||
Reference in New Issue
Block a user