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

Unified Diff: vm/datastream.h

Issue 10908185: Do not allocate a buffer of 64KB by default when writing a message out. Start (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/runtime/
Patch Set: Created 8 years, 3 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « vm/dart_api_message.h ('k') | vm/object.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: vm/datastream.h
===================================================================
--- vm/datastream.h (revision 12139)
+++ vm/datastream.h (working copy)
@@ -130,23 +130,22 @@
// Stream for writing various types into a buffer.
class WriteStream : public ValueObject {
public:
- static const intptr_t kBufferIncrementSize = 64 * KB;
-
- WriteStream(uint8_t** buffer, ReAlloc alloc) :
+ WriteStream(uint8_t** buffer, ReAlloc alloc, intptr_t increment_size) :
buffer_(buffer),
end_(NULL),
current_(NULL),
current_size_(0),
- alloc_(alloc) {
+ alloc_(alloc),
+ increment_size_(increment_size) {
ASSERT(buffer != NULL);
ASSERT(alloc != NULL);
*buffer_ = reinterpret_cast<uint8_t*>(alloc_(NULL,
0,
- kBufferIncrementSize));
+ increment_size_));
ASSERT(*buffer_ != NULL);
current_ = *buffer_;
- current_size_ = kBufferIncrementSize;
- end_ = *buffer_ + kBufferIncrementSize;
+ current_size_ = increment_size_;
+ end_ = *buffer_ + increment_size_;
}
uint8_t* buffer() const { return *buffer_; }
@@ -230,7 +229,7 @@
void Resize(intptr_t size_needed) {
intptr_t position = current_ - *buffer_;
intptr_t new_size = current_size_ +
- Utils::RoundUp(size_needed, kBufferIncrementSize);
+ Utils::RoundUp(size_needed, increment_size_);
*buffer_ = reinterpret_cast<uint8_t*>(alloc_(*buffer_,
current_size_,
new_size));
@@ -247,6 +246,7 @@
uint8_t* current_;
intptr_t current_size_;
ReAlloc alloc_;
+ intptr_t increment_size_;
DISALLOW_COPY_AND_ASSIGN(WriteStream);
};
« no previous file with comments | « vm/dart_api_message.h ('k') | vm/object.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698