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

Unified Diff: mojo/public/bindings/lib/buffer.cc

Issue 76943002: Have ScratchBuffer::Allocate prefer allocating on the stack even if a previous (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebase to other CL Created 7 years, 1 month 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 | « no previous file | mojo/public/tests/buffer_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: mojo/public/bindings/lib/buffer.cc
diff --git a/mojo/public/bindings/lib/buffer.cc b/mojo/public/bindings/lib/buffer.cc
index b5b9e7d815a4d6533686b3e9b6aca13f866c34ab..3ad964629ca1d2f1d47f3fc130e6097dc41e4fc2 100644
--- a/mojo/public/bindings/lib/buffer.cc
+++ b/mojo/public/bindings/lib/buffer.cc
@@ -34,13 +34,18 @@ ScratchBuffer::~ScratchBuffer() {
void* ScratchBuffer::Allocate(size_t delta) {
delta = internal::Align(delta);
- void* result =
- AllocateInSegment((overflow_ != NULL) ? overflow_ : &fixed_, delta);
+ void* result = AllocateInSegment(&fixed_, delta);
if (result)
return result;
+ if (overflow_) {
+ result = AllocateInSegment(overflow_, delta);
+ if (result)
+ return result;
+ }
+
AddOverflowSegment(delta);
- return Allocate(delta);
+ return AllocateInSegment(overflow_, delta);
}
void* ScratchBuffer::AllocateInSegment(Segment* segment, size_t delta) {
« no previous file with comments | « no previous file | mojo/public/tests/buffer_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698