From c7793128368c8d231ffb7989aa5cafb07ba47498 Mon Sep 17 00:00:00 2001 From: DreamPiggy Date: Wed, 8 Mar 2023 14:40:44 +0800 Subject: [PATCH] Use kvImageNoAllocate to avoid extra allocate for vImageBuffer when WebP encoding --- SDWebImageWebPCoder/Classes/SDImageWebPCoder.m | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/SDWebImageWebPCoder/Classes/SDImageWebPCoder.m b/SDWebImageWebPCoder/Classes/SDImageWebPCoder.m index 7b44810..6b95c09 100644 --- a/SDWebImageWebPCoder/Classes/SDImageWebPCoder.m +++ b/SDWebImageWebPCoder/Classes/SDImageWebPCoder.m @@ -782,7 +782,7 @@ static inline CGImageRef __nullable CGBitmapContextCreateScaledImage(cg_nullable } vImage_Buffer src; - error = vImageBuffer_InitWithCGImage(&src, &srcFormat, nil, imageRef, kvImageNoFlags); + error = vImageBuffer_InitWithCGImage(&src, &srcFormat, nil, imageRef, kvImageNoAllocate); if (error != kvImageNoError) { vImageConverter_Release(convertor); return nil; @@ -792,7 +792,6 @@ static inline CGImageRef __nullable CGBitmapContextCreateScaledImage(cg_nullable error = vImageBuffer_Init(&dest, height, width, destFormat.bitsPerPixel, kvImageNoFlags); if (error != kvImageNoError) { vImageConverter_Release(convertor); - free(src.data); return nil; } @@ -800,7 +799,6 @@ static inline CGImageRef __nullable CGBitmapContextCreateScaledImage(cg_nullable error = vImageConvert_AnyToAny(convertor, &src, &dest, NULL, kvImageNoFlags); // Free the buffer - free(src.data); vImageConverter_Release(convertor); if (error != kvImageNoError) { free(dest.data);