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

Unified Diff: runtime/vm/datastream.h

Issue 12578009: - Canonicalize types, type_arguments only when the object is marked as being from the core librarie… (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 7 years, 9 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 | « runtime/vm/dart_api_message.h ('k') | runtime/vm/heap.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: runtime/vm/datastream.h
===================================================================
--- runtime/vm/datastream.h (revision 20419)
+++ runtime/vm/datastream.h (working copy)
@@ -136,22 +136,22 @@
// Stream for writing various types into a buffer.
class WriteStream : public ValueObject {
public:
- WriteStream(uint8_t** buffer, ReAlloc alloc, intptr_t increment_size) :
+ WriteStream(uint8_t** buffer, ReAlloc alloc, intptr_t initial_size) :
buffer_(buffer),
end_(NULL),
current_(NULL),
current_size_(0),
alloc_(alloc),
- increment_size_(increment_size) {
+ initial_size_(initial_size) {
ASSERT(buffer != NULL);
ASSERT(alloc != NULL);
*buffer_ = reinterpret_cast<uint8_t*>(alloc_(NULL,
0,
- increment_size_));
+ initial_size_));
ASSERT(*buffer_ != NULL);
current_ = *buffer_;
- current_size_ = increment_size_;
- end_ = *buffer_ + increment_size_;
+ current_size_ = initial_size_;
+ end_ = *buffer_ + initial_size_;
}
uint8_t* buffer() const { return *buffer_; }
@@ -234,8 +234,12 @@
void Resize(intptr_t size_needed) {
intptr_t position = current_ - *buffer_;
- intptr_t new_size = current_size_ +
- Utils::RoundUp(size_needed, increment_size_);
+ intptr_t increment_size = current_size_;
+ if (size_needed > increment_size) {
+ increment_size = Utils::RoundUp(size_needed, initial_size_);
+ }
+ intptr_t new_size = current_size_ + increment_size;
+ ASSERT(new_size > current_size_);
*buffer_ = reinterpret_cast<uint8_t*>(alloc_(*buffer_,
current_size_,
new_size));
@@ -252,7 +256,7 @@
uint8_t* current_;
intptr_t current_size_;
ReAlloc alloc_;
- intptr_t increment_size_;
+ intptr_t initial_size_;
DISALLOW_COPY_AND_ASSIGN(WriteStream);
};
« no previous file with comments | « runtime/vm/dart_api_message.h ('k') | runtime/vm/heap.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698