• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Strange Bottleneck
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Strange Bottleneck


  • Subject: Re: Strange Bottleneck
  • From: Steve Cunningham <email@hidden>
  • Date: Fri, 6 Jun 2003 08:00:22 -0400

>At 5:04 PM -0400 05/06/03, Steve Cunningham wrote:
>> if the list_position > 0 then
>> error "list position > 0" number 101
>> return false
>
>Emmanuel wote:
>Not your fault, Steve ... but your script is no good copying now I'm afraid.

Well, at least it runs faster that way :-). Funny, it appears in my "sent
mail" box as "less than or equal to" (ascii 242), but I guess the list
doesn't recognize the extended character set. Newbie mistake.

Here's the rewritten version:

on makeMatrix()

script matrix

property nRows : 0
property nColumns : 0
property rows : {}
property columns : {}
property syncRC : true -- allows skiping row-column sync on first build
property time_list : ""

on insertRow(newRow, valueList)
set rows to insert_listitem(rows, valueList, newRow)
set nRows to nRows + 1
if syncRC then
set nColumns to count of valueList
if nRows = 1 then
repeat with nn from 1 to nColumns
set columns to columns & {{item nn of valueList}}
end repeat
else

-- ** This is the problem area ***
repeat with nn from 1 to nColumns
set t_start to GetMilliSec
set item nn of columns to insert_listitem(item nn of columns, item
nn of valueList, newRow)
set t_end to GetMilliSec
set elaspsed_time to (t_end - t_start)
if nn = nColumns then
set time_list to time_list & ("Row " & newRow & ", Column " & nn &
": " & elaspsed_time & " ms" & return)
end if
end repeat
-- ** End of the problem area ***

end if -- first row
end if -- synch columns
end insertRow

on insert_listitem(this_list, this_item, list_position)
set the list_count to the count of this_list
-- THE LIST POSITION INDICATES THE POSITION IN THE LIST
-- YOU WANT THE ADDED ITEM TO OCCUPY

-- Check within allowable range
if the list_position is less than or equal to 0 then
error "list position is less than or equal to 0" number 101
return false
else if the list_position is greater than the list_count + 1 then
error "list position is greater than or equal to 1 plus current size"
number 102
return false
end if

-- insert the item
if the list_position is 1 then
set the beginning of this_list to this_item
else if the list_position is (the list_count + 1) then
set the end of this_list to this_item
else
set this_list to (items 1 thru (list_position - 1) of this_list) & ,
{this_item} & (items list_position thru -1 of this_list)
end if
return this_list
end insert_listitem


end script -- Matrix
return matrix
end makeMatrix


set aMatrix to makeMatrix()
set testRows to 5
set testColumns to 5
set dummyRow to {}
repeat with nn from 1 to testColumns
set dummyRow to dummyRow & "x" as list
end repeat
repeat with nn from 1 to testRows
insertRow(nn, dummyRow) of aMatrix
end repeat

time_list of aMatrix
(* -->
"Row 2, Column 90: 4.0 ms
Row 3, Column 90: 5.0 ms
Row 4, Column 90: 6.0 ms
Row 5, Column 90: 6.0 ms
Row 6, Column 90: 7.0 ms
Row 7, Column 90: 8.0 ms
Row 8, Column 90: 8.0 ms
Row 9, Column 90: 9.0 ms
Row 10, Column 90: 10.0 ms
Row 11, Column 90: 12.0 ms
Row 12, Column 90: 12.0 ms
Row 13, Column 90: 13.0 ms
Row 14, Column 90: 13.0 ms
Row 15, Column 90: 14.0 ms
Row 16, Column 90: 15.0 ms
Row 17, Column 90: 17.0 ms
Row 18, Column 90: 16.0 ms
Row 19, Column 90: 17.0 ms
Row 20, Column 90: 18.0 ms
Row 21, Column 90: 19.0 ms
Row 22, Column 90: 20.0 ms
Row 23, Column 90: 21.0 ms
Row 24, Column 90: 36.0 ms
Row 25, Column 90: 22.0 ms
Row 26, Column 90: 24.0 ms
Row 27, Column 90: 24.0 ms
Row 28, Column 90: 25.0 ms
Row 29, Column 90: 25.0 ms
Row 30, Column 90: 27.0 ms
Row 31, Column 90: 27.0 ms
Row 32, Column 90: 28.0 ms
Row 33, Column 90: 28.0 ms
Row 34, Column 90: 29.0 ms
Row 35, Column 90: 30.0 ms
Row 36, Column 90: 30.0 ms
Row 37, Column 90: 32.0 ms
Row 38, Column 90: 33.0 ms
Row 39, Column 90: 34.0 ms
Row 40, Column 90: 34.0 ms
" *)
_______________________________________________
applescript-users mailing list | email@hidden
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/applescript-users
Do not post admin requests to the list. They will be ignored.

  • Prev by Date: Re: by-value vs by reference (was Re: list question)
  • Next by Date: Re: by-value vs by reference (was Re: list question)
  • Previous by thread: Re: Strange Bottleneck
  • Next by thread: Re: Strange Bottleneck
  • Index(es):
    • Date
    • Thread