| 3996 | } |
| 3997 | |
| 3998 | size_t buf_find(const std::string& s) const { |
| 3999 | auto c = s.front(); |
| 4000 | |
| 4001 | size_t off = buf_spos_; |
| 4002 | while (off < buf_epos_) { |
| 4003 | auto pos = off; |
| 4004 | while (true) { |
| 4005 | if (pos == buf_epos_) { return buf_size(); } |
| 4006 | if (buf_[pos] == c) { break; } |
| 4007 | pos++; |
| 4008 | } |
| 4009 | |
| 4010 | auto remaining_size = buf_epos_ - pos; |
| 4011 | if (s.size() > remaining_size) { return buf_size(); } |
| 4012 | |
| 4013 | if (start_with(buf_, pos, buf_epos_, s)) { return pos - buf_spos_; } |
| 4014 | |
| 4015 | off = pos + 1; |
| 4016 | } |
| 4017 | |
| 4018 | return buf_size(); |
| 4019 | } |
| 4020 | |
| 4021 | void buf_append(const char* data, size_t n) { |
| 4022 | auto remaining_size = buf_size(); |