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/.