Skip to content

Commit 6bb027c

Browse files
refactor: merge collapsible if statements
Nested `if` statements can be collapsed into a single `if` statement by separating their condition using `and` operator. Merging collapsible `if` statements increases the code's readability.
1 parent b8fac10 commit 6bb027c

File tree

1 file changed

+7
-5
lines changed

1 file changed

+7
-5
lines changed

python/trim_looped_video.py

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -47,11 +47,13 @@ def find_loop_point(video_path):
4747
# Convert frame to grayscale for easier comparison
4848
gray_frame = cv2.cvtColor(frame, cv2.COLOR_BGR2GRAY)
4949

50-
if prev_frame is not None:
51-
if is_similar_image(gray_frame, prev_frame):
52-
# Loop detected
53-
cap.release()
54-
return frame_index / fps
50+
if (
51+
prev_frame is not None
52+
and is_similar_image(gray_frame, prev_frame)
53+
):
54+
# Loop detected
55+
cap.release()
56+
return frame_index / fps
5557

5658
prev_frame = gray_frame
5759

0 commit comments

Comments
 (0)