Skip to content

Commit db09bf7

Browse files
perf(module:qr-code): improved background drawing efficiency (#8543)
1 parent 65cbb4e commit db09bf7

File tree

1 file changed

+2
-6
lines changed

1 file changed

+2
-6
lines changed

components/qr-code/qrcode.ts

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -105,12 +105,8 @@ export function drawCanvasBackground(
105105
scale: number,
106106
backgroundColor: string
107107
): void {
108-
for (let y = 0; y < height; y++) {
109-
for (let x = 0; x < width; x++) {
110-
ctx.fillStyle = backgroundColor;
111-
ctx.fillRect(x * scale, y * scale, scale, scale);
112-
}
113-
}
108+
ctx.fillStyle = backgroundColor;
109+
ctx.fillRect(0, 0, width * scale, height * scale);
114110
}
115111

116112
export function formatPadding(padding: number | number[]): number[] {

0 commit comments

Comments
 (0)