From fbcbd2a001be56ba1a95cd5fef9079fddd50aef1 Mon Sep 17 00:00:00 2001 From: Hajime Hoshi Date: Mon, 21 Mar 2022 04:36:32 +0900 Subject: [PATCH] internal/buffered: refactoring --- internal/buffered/image.go | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/internal/buffered/image.go b/internal/buffered/image.go index 44cd531e3..d3f05299c 100644 --- a/internal/buffered/image.go +++ b/internal/buffered/image.go @@ -116,13 +116,15 @@ func (i *Image) invalidatePendingPixels() { } func (i *Image) resolvePendingPixels(keepPendingPixels bool) { - if i.needsToResolvePixels { - i.img.ReplacePixels(i.pixels, nil) - if !keepPendingPixels { - i.pixels = nil - } - i.needsToResolvePixels = false + if !i.needsToResolvePixels { + return } + + i.img.ReplacePixels(i.pixels, nil) + if !keepPendingPixels { + i.pixels = nil + } + i.needsToResolvePixels = false } func (i *Image) MarkDisposed() {