From: Joe Van Dyk Date: 2005-07-13T12:03:22+09:00 Subject: Re: Updating GUIs On 7/12/05, Daniel Brockman wrote: > Joe Van Dyk writes: > > > This is taking me about a third of a second to do. Seems a bit high > > if I want to do this at least twice a second and leave room on the > > machine to do other things: > > [...] > > > player.polygon = player.polygon.collect do |x,y| > > How about this? > > player.polygon.collect! do |x,y| Didn't increase speed at all. > > > So what's the next step when trying to optimize this? Convert the > > rotate function to C? Or can I use a different algorithm? > > I didn't look at your algorithm, but before starting to convert stuff > into C, I'd try eliminating the extra object creation. I don't know > how much time it'll buy you, but maybe even try making `rotate' > destructively change the array instead of returning a new one. I could try that. Is there some Ruby idiom for going through every element in an array and destructively changing the values in it? Using collect! didn't seem to help at all.