Skip to content

Commit b428d1a

Browse files
committed
Apply same early return style in size.setter
1 parent 60535fc commit b428d1a

File tree

1 file changed

+10
-8
lines changed

1 file changed

+10
-8
lines changed

arcade/sprite/base.py

+10-8
Original file line numberDiff line numberDiff line change
@@ -239,16 +239,18 @@ def size(self, new_value: Point2):
239239
"size must be a tuple-like object which unpacks to exactly 2 coordinates"
240240
)
241241
old_size = self._size
242-
if old_size[0] != width or old_size[1] != height:
243-
texture_size = self._texture.size
244-
new_size = Vec2(width, height)
245-
self._scale = new_size / texture_size
246-
self._size = new_size
242+
if old_size[0] == width and old_size[1] == height:
243+
return
247244

248-
self.update_spatial_hash()
245+
texture_size = self._texture.size
246+
new_size = Vec2(width, height)
247+
self._scale = new_size / texture_size
248+
self._size = new_size
249249

250-
for sprite_list in self.sprite_lists:
251-
sprite_list._update_size(self)
250+
self.update_spatial_hash()
251+
252+
for sprite_list in self.sprite_lists:
253+
sprite_list._update_size(self)
252254

253255
@property
254256
def scale_x(self) -> float:

0 commit comments

Comments
 (0)