Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(253)

Side by Side Diff: runtime/platform/text_buffer.cc

Issue 2254543006: Reduce copying in sending service responses. (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: dbc, sync Created 4 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « runtime/platform/text_buffer.h ('k') | runtime/vm/dart_api_impl.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a 2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file. 3 // BSD-style license that can be found in the LICENSE file.
4 4
5 #include "platform/text_buffer.h" 5 #include "platform/text_buffer.h"
6 6
7 #include "platform/assert.h" 7 #include "platform/assert.h"
8 #include "platform/globals.h" 8 #include "platform/globals.h"
9 #include "platform/utils.h" 9 #include "platform/utils.h"
10 #include "vm/os.h" 10 #include "vm/os.h"
(...skipping 14 matching lines...) Expand all
25 buf_ = NULL; 25 buf_ = NULL;
26 } 26 }
27 27
28 28
29 void TextBuffer::Clear() { 29 void TextBuffer::Clear() {
30 msg_len_ = 0; 30 msg_len_ = 0;
31 buf_[0] = '\0'; 31 buf_[0] = '\0';
32 } 32 }
33 33
34 34
35 const char* TextBuffer::Steal() { 35 char* TextBuffer::Steal() {
36 const char* r = buf_; 36 char* r = buf_;
37 buf_ = NULL; 37 buf_ = NULL;
38 buf_size_ = 0; 38 buf_size_ = 0;
39 msg_len_ = 0; 39 msg_len_ = 0;
40 return r; 40 return r;
41 } 41 }
42 42
43 43
44 void TextBuffer::AddChar(char ch) { 44 void TextBuffer::AddChar(char ch) {
45 EnsureCapacity(sizeof(ch)); 45 EnsureCapacity(sizeof(ch));
46 buf_[msg_len_] = ch; 46 buf_[msg_len_] = ch;
(...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after
152 // the debugger front-end. 152 // the debugger front-end.
153 intptr_t new_size = buf_size_ + len + kBufferSpareCapacity; 153 intptr_t new_size = buf_size_ + len + kBufferSpareCapacity;
154 char* new_buf = reinterpret_cast<char*>(realloc(buf_, new_size)); 154 char* new_buf = reinterpret_cast<char*>(realloc(buf_, new_size));
155 ASSERT(new_buf != NULL); 155 ASSERT(new_buf != NULL);
156 buf_ = new_buf; 156 buf_ = new_buf;
157 buf_size_ = new_size; 157 buf_size_ = new_size;
158 } 158 }
159 } 159 }
160 160
161 } // namespace dart 161 } // namespace dart
OLDNEW
« no previous file with comments | « runtime/platform/text_buffer.h ('k') | runtime/vm/dart_api_impl.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698