Closed ChrisFullmer closed 11 years ago
Can we link to the line?
https://github.com/SketchUp/sketchup-stl/blob/master/src/sketchup-stl/importer.rb#L433
Why yes. Yes we can.
I see it being used on line 440
https://github.com/SketchUp/sketchup-stl/blob/master/src/sketchup-stl/importer.rb#L440
I'm now wondering why a constant would be faster? Both the current local variable and a constant would just be a reference to an Array of one Geom::Vector3d object in memory. What makes the constant faster if both are references?
hmm, I think I ran a faulty speed test earlier on this. In my testing it was about 5 times faster. Over 10,000,000 iterations, it save 2 seconds :)
I just re-created it and realized my logic was flawed. In my earlier test, I had put the "offset_reverse = [Z_AXIS.reverse]" part INSIDE my loop, so it recalculated it each time it looped.
Looking at it again, I see no speed benefit in making this change.
So this is a closed case?
In importer.rb line 433:
offset_reverse could be a CONSTANT (initialized at the top of the class with the other constants) if it is always (0,0,-1) to help speed up its use on line 440.