This is the mail archive of the
libstdc++@gcc.gnu.org
mailing list for the libstdc++ project.
Re: [v3] libstdc++/16612
Benjamin Kosnik wrote:
Ok, here we go again. I believe this to now be conformant. Hurray.
I'll wait 24 hrs for comments, and then check in a backport. (Which I
believe will be possible for 3.4/4.0).
Hi Benjamin.
Frankly, I cannot support this kind of approach:
*************** namespace std
*** 614,620 ****
operator[] (size_type __pos) const
{
_GLIBCXX_DEBUG_ASSERT(__pos <= size());
! return _M_data()[__pos];
}
/**
--- 621,631 ----
operator[] (size_type __pos) const
{
_GLIBCXX_DEBUG_ASSERT(__pos <= size());
! _CharT* __p = _M_data();
! if (__p)
! return __p[__pos];
! else
! return _Rep::_S_terminal;
}
Having a conditional for the most fundamental operation, that is
character access, doesn't seem a price that can be paid in order to
easily support shared memory.
At least, we have to carry out complete benchmarks, and I want to ear
Nathan about this: in my opinion, the very idea of the empty_rep was
meant to avoid this kind of performance issues in his original design.
If really, we cannot avoid this approach, then we should use it *only*
in the shared memory case/making it configurable at build time.
Paolo.