Avoid multi-processor bus contention on increment/decrement-and- test of the referenc...
authorNathan C. Myers <ncm-nospam@cantrip.org>
Fri, 13 Jun 2003 20:59:42 +0000 (20:59 +0000)
committerPaolo Carlini <paolo@gcc.gnu.org>
Fri, 13 Jun 2003 20:59:42 +0000 (20:59 +0000)
commitca566e4c075bfec8b4c4aab9fb6d6707f0a63b5a
tree93548ad6fc3770e67322116c7c4cf63b2aaf9778
parent9f629a219154cf0b501355215fb3b73f0a2b71b2
Avoid multi-processor bus contention on increment/decrement-and- test of the reference count in the empty-string object...

2003-06-13  Nathan C. Myers <ncm-nospam@cantrip.org>

Avoid multi-processor bus contention on increment/decrement-and-
test of the reference count in the empty-string object, by comparing
        addresses first, and never touching the reference count of the empty-
        string object.
* include/bits/basic_string.h:
(_S_empty_rep_storage): Move into basic_string<>::_Rep for use by its
members.
(_Rep::_S_empty_rep()): New accessor.
(_Rep::_M_length, _Rep::_M_capacity, _Rep::_M_references): Move to
a base class _Rep_base.
(_Rep::_M_dispose, _Rep::_M_refcopy): Check for the empty string.
(basic_string()): Change to use _M_refdata() in place of _M_refcopy(),
since no longer must increment its refcount.
* include/bits/basic_string.tcc:
(_Rep::_M_destroy, _M_leak_hard): Check for the empty string and
        return immediately.  The former might be unnecessary.  The latter
        prevents begin() and end() from cloning it unnecessarily.
(_S_construct(_InIterator, _InIterator, const _Alloc&,
input_iterator_tag), _S_construct(_InIterator, _InIterator,
const _Alloc&, forward_iterator_tag), _S_construct(size_type, _CharT,
const _Alloc&)): Change to use _M_refdata() in place of _M_refcopy().
(_M_mutate): Check for the empty string and treat it as shared.
        This is necessary here because _M_mutate is sometimes called with
        all-zero arguments; in all other uses of _M_is_shared, the test comes
        out right anyhow.

From-SVN: r67912
libstdc++-v3/ChangeLog
libstdc++-v3/include/bits/basic_string.h
libstdc++-v3/include/bits/basic_string.tcc