From 85b0611ca0906b157f3ac6c96fc62a0e35af9776 Mon Sep 17 00:00:00 2001 From: kleonc <9283098+kleonc@users.noreply.github.com> Date: Wed, 20 Jan 2021 22:29:40 +0100 Subject: [PATCH] Speedup Draw.update_mask() (#439) --- src/Tools/Draw.gd | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/Tools/Draw.gd b/src/Tools/Draw.gd index 52b52b7..ec60da8 100644 --- a/src/Tools/Draw.gd +++ b/src/Tools/Draw.gd @@ -131,10 +131,10 @@ func update_mirror_brush() -> void: func update_mask() -> void: var size := _get_draw_image().get_size() - _mask = PoolByteArray() - _mask.resize(size.x * size.y) - for i in _mask.size(): - _mask[i] = 0 + # Faster then zeroing PoolByteArray directly. See: https://github.com/Orama-Interactive/Pixelorama/pull/439 + var nulled_array := [] + nulled_array.resize(size.x * size.y) + _mask = PoolByteArray(nulled_array) func update_line_polylines(start : Vector2, end : Vector2) -> void: