On 16/11/2015 11:29, Jonathan Wakely wrote: > On 15/11/15 22:12 +0100, François Dumont wrote: >> Here is a last version I think. >> >> I completed the debug light mode by adding some check on iterator >> ranges. >> >> Even if check are light I made some changes to make sure that >> internally vector is not using methods instrumented with those checks. >> This is to make sure checks are not done several times. Doing so also >> simplify normal mode especially when using insert range, there is no >> need to check if parameters are integers or not. > > Yes, I'd also observed that those improvements could be made, to avoid > dispatching when we already know we have iterators not integers.
I will keep those simplification even if I remove some checks. > >> I also introduce some __builtin_expect to make sure compiler will >> prefer the best path. >> >> I didn't manage to check result on generated code. I am pretty sure >> there will be an impact, you can't run more code without impact. But >> that is a known drawback of debug mode, light or not, we just need to >> minimize it. Mostly by making sure that checks are done only once. > > Not doing the checks is also an option. That minimizes the cost :-) This is controlled by a macro, users already have this option. > > For the full debug mode we want to check everything we can, and accept > that has a cost. > > For the lightweight one we need to evaluate the relative benefits. Is > it worth adding checks for errors that only happen rarely? Does the > benefit outweigh the cost? > > I'm still not convinced that's the case for the "valid range" checks. > I'm willing to be convinced, but am not convinced yet. Ok so I will remove this check. And what about insert position check ? I guess this one too so I will remove it too. Note that will only remain checks on the most basic operations that is to say those on which the check will have the biggest impact proportionally. I would like we push the simplest version so that people can start experimenting. I would also prefer concentrate on _GLIBCXX_DEBUG mode :-) > >> It would be great to have it for gcc 6.0. I am working on the same >> for other containers. > > Please don't do the valid range checks for std::deque, the checks are > undefined for iterators into different containers and will not give a > reliable answer. But debug mode is full of those checks, no ? François