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

Unified Diff: Source/core/inspector/InspectorLayerTreeAgent.cpp

Issue 559103002: Reduce memory peaks when generating data urls for images. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Created 6 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 | « no previous file | Source/platform/graphics/ImageBuffer.cpp » ('j') | Source/platform/graphics/ImageBuffer.cpp » ('J')
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/core/inspector/InspectorLayerTreeAgent.cpp
diff --git a/Source/core/inspector/InspectorLayerTreeAgent.cpp b/Source/core/inspector/InspectorLayerTreeAgent.cpp
index 27eb0d398047cde607bcd99e777f691e694f2dc3..88ae87c6f415a9cfb3a7db965ac4e3612ce61c7c 100644
--- a/Source/core/inspector/InspectorLayerTreeAgent.cpp
+++ b/Source/core/inspector/InspectorLayerTreeAgent.cpp
@@ -53,6 +53,7 @@
#include "public/platform/WebFloatPoint.h"
#include "public/platform/WebLayer.h"
#include "wtf/text/Base64.h"
+#include "wtf/text/StringBuilder.h"
namespace blink {
@@ -383,7 +384,11 @@ void InspectorLayerTreeAgent::replaySnapshot(ErrorString* errorString, const Str
*errorString = "Image encoding failed";
return;
}
- *dataURL = "data:image/png;base64," + *base64Data;
+ StringBuilder url;
pdr. 2014/09/11 04:38:15 Any reason for not using reserveCapacity before ap
Daniel Bratell 2014/09/11 11:22:31 I don't think I had seen that document before. It
+ url.append("data:image/png;base64,");
Noel Gordon 2014/09/11 02:39:45 per https://trac.webkit.org/wiki/EfficientStrings,
+ url.reserveCapacity(url.length() + base64Data->size()); // Prevent over-allocation.
Noel Gordon 2014/09/11 01:03:23 nit: remove the comment.
Daniel Bratell 2014/09/11 11:22:31 Done.
+ url.append(base64Data->begin(), base64Data->size());
+ *dataURL = url.toString();
}
void InspectorLayerTreeAgent::profileSnapshot(ErrorString* errorString, const String& snapshotId, const int* minRepeatCount, const double* minDuration, RefPtr<TypeBuilder::Array<TypeBuilder::Array<double> > >& outTimings)
« no previous file with comments | « no previous file | Source/platform/graphics/ImageBuffer.cpp » ('j') | Source/platform/graphics/ImageBuffer.cpp » ('J')

Powered by Google App Engine
This is Rietveld 408576698