Remove mail message doubles

Hi,
i’ll encourage you to improve my script or to suggest somewhat better. I want to learn.
(the script below removes mail doubles from user group mails- .and the cleanup handler is there because the whole script I wrote is a bit longer)

tell application "Mail" to set d to messages of mailbox "INBOX" of account "Gmail"
my clean_sim(d)

on clean_sim(d)
--set {cu_m, cu_y} to {month of (current date), year of (current date)}
	set {delete_ls, sim_ls} to {{}, {}}
	repeat with i from 1 to count of d
		set gt_message to item i of d
		tell application "Mail"
			set {gt_sub, rvm, rvy, lg} to {subject of gt_message as text, month of (get date received of gt_message), year of (get date received of gt_message), length of (get content of gt_message)}
		end tell
		--if rvm = cu_m and rvy = cu_y then
			if gt_sub is not in sim_ls then
				copy gt_sub to sim_ls
				copy {gt_sub, lg, rvm, rvy} to {o_sub, o_lg, o_m, o_y}
			else
				if rvy ≤ o_y and rvm ≤ o_m and lg ≤ o_lg then copy gt_message to end of delete_ls
				--if lg ≤ o_lg then copy gt_message to end of delete_ls
			end if
		--end if
	end repeat
	--clean up
	my cleanup(delete_ls)
end clean_sim

on cleanup(delete_ls)
	repeat with i in delete_ls
		delete i
	end repeat
end cleanup

Hi,

I have only one suggestion

. copy {gt_sub, lg, rvm, rvy} to {o_sub, o_lg, o_m, o_y} .
is extremely hard to read. The times of 8.3 filenames or 640 kB RAM are definitely over :wink: