Good point. Even after cleaning my ASObjC code, yours is faster.
use AppleScript version "2.5" -- Mac OS 10.11 (El Capitan) or later.
use framework "Foundation"
use scripting additions
set startDate to current application's NSDate's |date|()
repeat 1000 times
tell application "Contacts" to tell group "Famille" to set phone_num_list to value of every phone of every person
set solicitor_list to {}
repeat with each_contact in my phone_num_list
repeat with each_phone_num in each_contact
set solicitor_list to solicitor_list & each_phone_num
end repeat
end repeat
solicitor_list
end repeat
set timeDiff to startDate's timeIntervalSinceNow()
display dialog "That took " & (-timeDiff as real) & " seconds."
--> "That took 7,900698006153 seconds."
My cleaned one:
-------------------------------------------------------------------------------------------
use AppleScript version "2.4"
use framework "Foundation"
use scripting additions
on cleanList:theList
set theArray to current application's NSMutableArray's arrayWithArray:theList
set unionOfArrays to (theArray's valueForKeyPath:"@unionOfArrays.self")
return unionOfArrays as list
end cleanList:
set startDate to current application's NSDate's |date|()
repeat 1000 times
tell application "Contacts"
tell group "Famille"
set phoneNumList to value of every phone of every person
end tell
end tell
set phoneNumList to its cleanList:phoneNumList
end repeat
set timeDiff to startDate's timeIntervalSinceNow()
display dialog "That took " & (-timeDiff as real) & " seconds."
--> "That took 8,027648031712 seconds."
-------------------------------------------------------------------------------------------
Yvan KOENIG running Sierra 10.12.2 in French (VALLAURIS, France) vendredi 6 janvier 2017 11:13:39