From 3d76b08bd82aac277309eac708ac71980ced005a Mon Sep 17 00:00:00 2001 From: hyperlife1119 Date: Tue, 21 May 2024 11:46:25 +0800 Subject: [PATCH] perf(module:qr-code): improved background drawing efficiency --- components/qr-code/qrcode.ts | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/components/qr-code/qrcode.ts b/components/qr-code/qrcode.ts index 0ea38fa9bd5..fd34e5657c2 100644 --- a/components/qr-code/qrcode.ts +++ b/components/qr-code/qrcode.ts @@ -105,12 +105,8 @@ export function drawCanvasBackground( scale: number, backgroundColor: string ): void { - for (let y = 0; y < height; y++) { - for (let x = 0; x < width; x++) { - ctx.fillStyle = backgroundColor; - ctx.fillRect(x * scale, y * scale, scale, scale); - } - } + ctx.fillStyle = backgroundColor; + ctx.fillRect(0, 0, width * scale, height * scale); } export function formatPadding(padding: number | number[]): number[] {