From 04d4d5433e517210c77fcd0bccaba76a0de57e66 Mon Sep 17 00:00:00 2001 From: "phajdan.jr@chromium.org" Date: Mon, 3 Aug 2009 23:35:24 +0000 Subject: Followup after http://codereview.chromium.org/149368 Fix minor issues in new ftp code. TEST=none BUG=none Review URL: http://codereview.chromium.org/160541 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@22347 0039d316-1c4b-4281-b951-d872f2087c98 --- net/ftp/ftp_ctrl_response_buffer.cc | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) (limited to 'net/ftp/ftp_ctrl_response_buffer.cc') diff --git a/net/ftp/ftp_ctrl_response_buffer.cc b/net/ftp/ftp_ctrl_response_buffer.cc index 02f9908..9441f4b 100644 --- a/net/ftp/ftp_ctrl_response_buffer.cc +++ b/net/ftp/ftp_ctrl_response_buffer.cc @@ -27,7 +27,7 @@ namespace net { const int FtpCtrlResponse::kInvalidStatusCode = -1; int FtpCtrlResponseBuffer::ConsumeData(const char* data, int data_length) { - buffer_.append(std::string(data, data_length)); + buffer_.append(data, data_length); ExtractFullLinesFromBuffer(); while (!lines_.empty()) { @@ -38,11 +38,10 @@ int FtpCtrlResponseBuffer::ConsumeData(const char* data, int data_length) { if (!line.is_complete) return ERR_INVALID_RESPONSE; + response_buf_.status_code = line.status_code; if (line.is_multiline) { line_buf_ = line.status_text; - response_buf_.status_code = line.status_code; } else { - response_buf_.status_code = line.status_code; response_buf_.lines.push_back(line.status_text); LogResponse(response_buf_); responses_.push(response_buf_); @@ -106,14 +105,11 @@ FtpCtrlResponseBuffer::ParsedLine FtpCtrlResponseBuffer::ParseLine( } void FtpCtrlResponseBuffer::ExtractFullLinesFromBuffer() { - std::string line_buf; int cut_pos = 0; for (size_t i = 0; i < buffer_.length(); i++) { - line_buf.push_back(buffer_[i]); if (i >= 1 && buffer_[i - 1] == '\r' && buffer_[i] == '\n') { - lines_.push(ParseLine(line_buf.substr(0, line_buf.length() - 2))); + lines_.push(ParseLine(buffer_.substr(cut_pos, i - cut_pos - 1))); cut_pos = i + 1; - line_buf.clear(); } } buffer_.erase(0, cut_pos); -- cgit v1.1