AppleScript名:offset ofの高速実行 |
set aDate to current date repeat 100000 times set aStr to "abcdefghi" set aRes to offset of "c" in aStr end repeat set bDate to current date –結果表示 display dialog (bDate – aDate) as string –> 通常で5秒、offset ofをフックして自前のサブルーチンで実行すると2秒 –offset命令の実行を横取りする on offset of searchStr in str set aRes to getOffset(str, searchStr) of me return aRes end offset on getOffset(str, searchStr) set d to divideBy(str, searchStr) if (count d) is less than 2 then return 0 return (length of item 1 of d) + 1 end getOffset on divideBy(str, separator) set delSave to AppleScript’s text item delimiters set the AppleScript’s text item delimiters to separator set strItems to every text item of str set the AppleScript’s text item delimiters to delSave return strItems end divideBy |
More from my site
(Visited 36 times, 1 visits today)