[patch/rfa] Tiny but delicate change to string::_M_mutate

Paolo Carlini pcarlini@suse.de
Sun Oct 17 13:10:00 GMT 2004


Nathan Myers wrote:

>....... Probably the logic should still check for _S_empty_rep
>to avoid touching its reference count:
>  
>
Sorry, Nathan, I misunderstood you: you are actually concerned by bus
contention on *reading* _S_empty_rep's _M_refcount, *not* on writing it!

Luckily, it seems we can futher tweak my proposal to reduce it largely.
Just swap the conditional:
   
    if (__new_size > capacity() || _M_rep()->_M_is_shared())

this way, when _S_empty_rep is concerned, we read _M_refcount *only*
when __new_size == capacity(), a not-so-common situation, compared to
the normal usage.

Paolo.



More information about the Libstdc++ mailing list