Skip to content

Commit c57a88d

Browse files
🔧 chore(main.py): refactor array processing logic for efficiency and readability
1 parent abc5924 commit c57a88d

File tree

1 file changed

+4
-10
lines changed

1 file changed

+4
-10
lines changed

‎main.py

+4-10
Original file line numberDiff line numberDiff line change
@@ -63,23 +63,17 @@ def handle_array(self, event):
6363
seen_files = set()
6464
unique_array = []
6565

66-
for item in self.array: # Loop through the array of files and process each one
66+
for item in reversed(self.array): # Loop through the array of files and process each one
6767
if item['file'] not in seen_files:
6868
unique_array.append(item)
6969
seen_files.add(item['file'])
7070

71-
self.array = unique_array # Update the `array` attribute with the list of unique files
72-
73-
for item in self.array:
74-
if item['file'] == event.src_path and item['status'] == 'processed':
75-
return False
76-
77-
for item in self.array:
7871
if item['file'] == event.src_path:
72+
if item['status'] == 'processed':
73+
return False
7974
item['status'] = 'processed' # Mark the file as processed
8075

81-
if len(self.array) > 10: # If the array has more than 10 items, remove the oldest ones
82-
self.array = self.array[-10:]
76+
self.array = unique_array[-10:] # Keep the last 10 items in the array
8377

8478
return True
8579

0 commit comments

Comments
 (0)