|
Geometry : |
Subject: Re: [geometry] warnings with gcc
From: Simonson, Lucanus J (lucanus.j.simonson_at_[hidden])
Date: 2012-01-18 16:29:21
>> There is one controversial one: the patch of point.hpp
>>
>> You have initialized the values to zero which is a logical thing to do. And
>> in this case I knew there were warnings. But... We don't want to initialize
>> them to zero... There was some correspondence about that years ago on the
>> Boost mailing list. People are quite sensitive to this. Like C++ does not
>> initialize an int to zero, we also don't want to do this to our points.
>
>Ah yes I kind of expected this one, I was pretty sure this was
>intentional. But if you don't initialize, there is a risk, right? OTOH
>it might be paying for something useless. As you're initializing in
>the second constructor, I'm wondering if there is not a way to use
>this, with a templated constructor and enable_if. I'll think about it
>and tell you if I have an idea.
The risk is that a program that depends on the uninitialized value will have different behavior depending on how it is compiled or even from run to run, which is hard to debug. The problem is that when you construct a vector of point the default constructor is called for each element, forcing memory fetch and setting each to zero. Then you go through the vector in a different loop to assign the actual value. This double access to the vector hurts performance significantly. The compiler will generally not be able to optimize out the unneeded initialization of the vector.
>PS: work-related question, did you hear about a polygon-skeleton algorithm with geometry? I'd be pretty interested in >such a thing.
There are several polygon-skeleton algorithms, so I assume you mean straight-skeleton. I have not heard of any straight-skeleton related work.
Polygon straight-skeleton is darn hard to do. There are correctness, performance and numerical robustness challenges. It would be a two year job for a strong software engineer. I'm considering it as a GSOC project for next year. Hopefully we can get a student working on it who will stick with the project after the end of the summer.
Regards,
Luke
Geometry list run by mateusz at loskot.net