From 6cb5570b87ae0d0e981462127178e8715ee596d7 Mon Sep 17 00:00:00 2001 From: Noel Grandin Date: Mon, 6 Feb 2023 16:30:54 +0200 Subject: [PATCH] no need for shared_ptr here avoid an allocation and some pointer chasing Signed-off-by: Noel Grandin Change-Id: I29711075d4bf840c2ef992341a6dadeeb87c6edd --- common/RenderTiles.hpp | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/common/RenderTiles.hpp b/common/RenderTiles.hpp index d451bafd5..0e7b5a103 100644 --- a/common/RenderTiles.hpp +++ b/common/RenderTiles.hpp @@ -293,8 +293,8 @@ namespace RenderTiles pngPool.pushWork([=,&output,&pixmap,&tiles,&renderedTiles, &pngMutex,&deltaGen]() { - auto data = std::shared_ptr>(new std::vector< char >()); - data->reserve(pixmapWidth * pixmapHeight * 1); + std::vector< char > data; + data.reserve(pixmapWidth * pixmapHeight * 1); // FIXME: don't try to store & create deltas for read-only documents. if (tiles[tileIndex].getId() < 0) // not a preview @@ -311,14 +311,14 @@ namespace RenderTiles tileCombined.getPart(), canonicalViewId ), - *data, wireId, forceKeyframe); + data, wireId, forceKeyframe); } else { // FIXME: write our own trivial PNG encoding code using deflate. LOG_TRC("Encode a new png for tile #" << tileIndex); if (!Png::encodeSubBufferToPNG(pixmap.data(), offsetX, offsetY, pixelWidth, pixelHeight, - pixmapWidth, pixmapHeight, *data, mode)) + pixmapWidth, pixmapHeight, data, mode)) { // FIXME: Return error. // sendTextFrameAndLogError("error: cmd=tile kind=failure"); @@ -327,10 +327,10 @@ namespace RenderTiles } } - LOG_TRC("Tile " << tileIndex << " is " << data->size() << " bytes."); + LOG_TRC("Tile " << tileIndex << " is " << data.size() << " bytes."); std::unique_lock pngLock(pngMutex); - output.insert(output.end(), data->begin(), data->end()); - pushRendered(renderedTiles, tiles[tileIndex], wireId, data->size()); + output.insert(output.end(), data.begin(), data.end()); + pushRendered(renderedTiles, tiles[tileIndex], wireId, data.size()); }); } tileIndex++;