You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@stdcxx.apache.org by Farid Zaripov <Fa...@kyiv.vdiweb.com> on 2007/02/14 18:03:21 UTC
[PATCH] Fix of STDCXX-127
Attached is a proposed patch for fix the bug STDCXX-127.
ChangeLog:
STDCXX-127
* deque (swap): Corrected _C_beg._C_node and _C_and._C_node
after swap operation for empty container.
Farid.
RE: [PATCH] Fix of STDCXX-127
Posted by Farid Zaripov <Fa...@kyiv.vdiweb.com>.
> -----Original Message-----
> From: Martin Sebor [mailto:sebor@roguewave.com]
> Sent: Wednesday, February 14, 2007 8:57 PM
> To: stdcxx-dev@incubator.apache.org
> Subject: Re: [PATCH] Fix of STDCXX-127
> Ft, since you assert that "if one of pointers is so must be
> the other" it seems to me that the condition in the if above
> could be simplified for efficiency to just (and the same below):
>
> if (pointer () == _C_beg._C_cur) {
> _RWSTD_ASSERT (pointer () == _C_end._C_cur);
> ...
> }
> else {
> _RWSTD_ASSERT (pointer () != _C_end._C_cur);
> }
>
Commited thus: http://svn.apache.org/viewvc?view=rev&rev=507940
> Second, since swap is not a trivial function anymore after
> this change (it could have been considered non-trivial even
> before it) we should outline it and move its definition to deque.cc.
Commited thus: http://svn.apache.org/viewvc?view=rev&rev=507942
> Do you agree?
Completely.
Farid.
Re: [PATCH] Fix of STDCXX-127
Posted by Martin Sebor <se...@roguewave.com>.
Farid Zaripov wrote:
> Attached is a proposed patch for fix the bug STDCXX-127.
>
> ChangeLog:
> STDCXX-127
> * deque (swap): Corrected _C_beg._C_node and _C_and._C_node
> after swap operation for empty container.
>
> Farid.
>
Cool. Two comments on this patch (copied below):
Index: deque
===================================================================
--- deque (revision 507528)
+++ deque (working copy)
@@ -904,6 +904,30 @@
_STD::swap (_C_end, __rhs._C_end);
_STD::swap (_C_nodes, __rhs._C_nodes);
_STD::swap (_C_node_size, __rhs._C_node_size);
+
+ if ( pointer() == _C_beg._C_cur
+ || pointer() == _C_end._C_cur) {
+
+ _RWSTD_ASSERT ( pointer() == _C_beg._C_cur
+ && pointer() == _C_end._C_cur);
Ft, since you assert that "if one of pointers is so must be
the other" it seems to me that the condition in the if above
could be simplified for efficiency to just (and the same below):
if (pointer () == _C_beg._C_cur) {
_RWSTD_ASSERT (pointer () == _C_end._C_cur);
...
}
else {
_RWSTD_ASSERT (pointer () != _C_end._C_cur);
}
Second, since swap is not a trivial function anymore after
this change (it could have been considered non-trivial even
before it) we should outline it and move its definition to
deque.cc.
Do you agree?
Martin