Merge pull request #71 from SDWebImage/perf/avoid_unused_copy

Avoid unused extra copy of MutableData
This commit is contained in:
DreamPiggy 2023-02-06 22:09:50 +08:00 committed by GitHub
commit e3c34ac58b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 2 additions and 3 deletions

View File

@ -307,8 +307,7 @@ else OSSpinLockUnlock(&lock##_deprecated);
_finished = finished; _finished = finished;
// check whether we can detect Animated WebP or Static WebP, they need different codec (Demuxer or IDecoder) // check whether we can detect Animated WebP or Static WebP, they need different codec (Demuxer or IDecoder)
if (!_hasAnimation) { if (!_hasAnimation) {
_imageData = [data copy]; VP8StatusCode status = WebPIUpdate(_idec, data.bytes, data.length);
VP8StatusCode status = WebPIUpdate(_idec, _imageData.bytes, _imageData.length);
// For Static WebP, all things done. // For Static WebP, all things done.
// For Animated WebP (currently use `VP8_STATUS_UNSUPPORTED_FEATURE` to check), continue to create demuxer // For Animated WebP (currently use `VP8_STATUS_UNSUPPORTED_FEATURE` to check), continue to create demuxer
if (status != VP8_STATUS_UNSUPPORTED_FEATURE) { if (status != VP8_STATUS_UNSUPPORTED_FEATURE) {
@ -324,7 +323,7 @@ else OSSpinLockUnlock(&lock##_deprecated);
WebPDemuxDelete(_demux); WebPDemuxDelete(_demux);
_demux = NULL; _demux = NULL;
} }
_imageData = [data copy]; _imageData = data;
WebPData webpData; WebPData webpData;
WebPDataInit(&webpData); WebPDataInit(&webpData);
webpData.bytes = _imageData.bytes; webpData.bytes = _imageData.bytes;