Re: Struct is slow
- From: Wayne Magor <wemagor2@xxxxxxxxx>
- Date: Thu, 25 Oct 2007 01:09:09 +0900
Just wanted to follow-up so people don't think there might be problems
with the Struct class. It isn't actually slow at all. The problem was
just that an inner loop was not converted from an array and so didn't
work and used a lot of CPU resources. Once fixed, I can't tell any
difference between the two versions.
It was this:
type_arr.each do |td_type, td_name|
if t == td_name then
primary_t = td_type
break
end
end
needed to be converted to this:
type_arr.each do |x|
if t == x.typedef_name then
primary_t = x.typedef_type
break
end
end
I used a different naming scheme in that loop (td_name instead of
typedef_name) which caused me not to find it when doing a search for all
places that needed to be converted to a struct.
This is one example where strong typing could have made a difference.
Had the array been declared as an array of arrays or array of structs,
perhaps another language could have detected the error. I'm not
advocating for strongly typed languages, I'm just saying that some kinds
of errors could be harder to find in Ruby. What do you folks think?
--
Posted via http://www.ruby-forum.com/.
.
- Follow-Ups:
- Re: Struct is slow
- From: Rick DeNatale
- Re: Struct is slow
- From: Robert Dober
- Re: Struct is slow
- References:
- Re: Struct is slow
- From: Robert Klemme
- Re: Struct is slow
- From: Sylvain Joyeux
- Re: Struct is slow
- From: Joel VanderWerf
- Re: Struct is slow
- From: Robert Klemme
- Re: Struct is slow
- From: Rick DeNatale
- Re: Struct is slow
- Prev by Date: Re: A Ruby/Rails bibliography
- Next by Date: Re: Ruby Certification Test
- Previous by thread: Re: Struct is slow
- Next by thread: Re: Struct is slow
- Index(es):
Relevant Pages
|