diff options
author | Ryan Mitchell <rtmitchell@google.com> | 2019-01-22 16:16:13 -0800 |
---|---|---|
committer | Ryan Mitchell <rtmitchell@google.com> | 2019-01-22 16:16:13 -0800 |
commit | f67808b78dad59ec6b28b53b2390ae08eb19cef8 (patch) | |
tree | f833c151d2b30eb3c40792113170b14d90aa49a3 /tools/aapt2/cmd/Compile.cpp | |
parent | 9ce77e9b7f0a1d001428030f3ad738220378ae40 (diff) |
Optimize aapt2 compile for pngs
Do not copy the png data when compiling pngs.
Bug: 122950060
Test: aapt2 compile -o . BaseAppPhoto1_copy.png
Change-Id: I78fbdaa9a40ada406d7b07cf072d6cd76124168e
Diffstat (limited to 'tools/aapt2/cmd/Compile.cpp')
-rw-r--r-- | tools/aapt2/cmd/Compile.cpp | 6 |
1 files changed, 1 insertions, 5 deletions
diff --git a/tools/aapt2/cmd/Compile.cpp b/tools/aapt2/cmd/Compile.cpp index 92beb4eb7ce4..0512bdc5bf72 100644 --- a/tools/aapt2/cmd/Compile.cpp +++ b/tools/aapt2/cmd/Compile.cpp @@ -469,16 +469,12 @@ static bool CompilePng(IAaptContext* context, const CompileOptions& options, return false; } - // Read the file as a string - char buffer_2[data->size()]; - memcpy(&buffer_2, data->data(), data->size()); - StringPiece content(buffer_2, data->size()); - BigBuffer crunched_png_buffer(4096); io::BigBufferOutputStream crunched_png_buffer_out(&crunched_png_buffer); // Ensure that we only keep the chunks we care about if we end up // using the original PNG instead of the crunched one. + const StringPiece content(reinterpret_cast<const char*>(data->data()), data->size()); PngChunkFilter png_chunk_filter(content); std::unique_ptr<Image> image = ReadPng(context, path_data.source, &png_chunk_filter); if (!image) { |