@unknownuser said:
One thing that cought me off guard is the breakpoints doesn't always work in Release due to compiler optimization. Visual Studio 2013 even has a nice profiler which let you get detailed profiling info of your C++ code. (Should do a quick tutorial on that once.)
Speaking of debuggers, you know taht from SU2014 you can hook up Ruby debuggers for Ruby code in SketchUp?
https://github.com/SketchUp/sketchup-ruby-debugger
It's so much nice to be able to set breakpoints and step than litter the code with puts.
Well this keeps gets better and better. I did not know that.
Have been sending puts to ruby console from C++ but that wont work when stepping over code, so this sounds great.
@unknownuser said:
You can do something similar C++ std::vector<>.reserve with the Ruby C API by calling rb_ary_new2. You provide the number of final elements and it will allocate enough memory of the object up front.
Handy! I do a lot of conversions so that will help. I'm not in a mode of optimizing code yet, but suppose best practices are worth picking up at an early stage.
I'm experiencing some problems in a loop here. Don't know if you can spot whats going on..
Have just included the important parts for brevity.
I have a nested ruby array of points curves. The points are coming from a getter-method-call in a Ruby-class. The @points can be of vary length.
The problem is that RARRAY(curve_rbPoints)->len always gives the same length, so the code fails..
Is it because I'm hoisting the variable ?
I just found this bug so havent tested much yet..
NOTE: I should mention it get's the correct length 1st time round.
edit: nope.
// VALUE curves = [ curve, curve, etc ] // @points = [point3d, point3d, etc]
const VALUE get_points = rb_intern("get_points"); //getter method for @points
int curves_size = RARRAY(curves)->len;
VALUE curve, curve_rbPoints;
int rCrv_len, i;
// Inside a loop
for (i = 0; i < curves_size; i++) {
curve = rb_ary_entry(curves, i); //My class Ec-curve instance"
curve_rbPoints = rb_funcall(curve, get_points, 0); //Gets @points in current curves[index]
rCrv_len = RARRAY(curve_rbPoints)->len; //WRONG LENGTH!
//Nested for loop is coming based on rCrv_len length